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各ディレクトリに対してマウントコマンドを実行する必要があります。あなたはそれを使用することができますread内蔵ループ周辺

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

おすすめ記事