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

관련 정보