1

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
Sridhar Sarnobat
  • 1,802
  • 20
  • 27

1 Answers1

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
fi

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