Is it possible to feed the branch paths from stdin to the mount (or mount_unionfs) command, instead of supplying them as arguments or from a file?

cat ~/dirs_with_photos.txt | mount -t unionfs

I don't want to use /etc/fstab, because ideally I want to automatically generate these txt files dynamically, such as with a cron job:

@weekly  find $HOME -type d -iname "*photos*" > ~/dirs_with_photos.txt

1 Answer 1


Transform the input into the required syntax and splice it into the command line with a command substitution.

dirs_with_photos="$(<~/dirs_with_photos.txt tr '\n' :)"
if [ -n "$dirs_with_photos" ]; then
  unionfs-fuse "${dirs_with_photos%:}" /photos

With mount_unionfs you need to issue one mount command per directory. You can use a loop around the read builtin.

while IFS= read -r dir; do
  mount_unionfs "$dir" /photos
done <~/dirs_with_photos.txt

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .