stdin から供給される unionfs (または aufs) ブランチをマウントしますか?

stdin から供給される unionfs (または aufs) ブランチをマウントしますか?

ブランチ パスを引数として、またはファイルから指定するのではなく、stdin から mount (または mount_unionfs) コマンドに渡すことは可能ですか?

cat ~/dirs_with_photos.txt | mount -t unionfs

/etc/fstab理想的には、cron ジョブなどを使用してこれらの txt ファイルを動的に自動生成したいので、は使用しません。

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

答え1

入力を必要な構文に変換し、コマンドラインに挿入します。コマンド置換

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

mount_unionfsディレクトリごとに1つのマウントコマンドを発行する必要があります。read組み込み関数をループする

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

関連情報