![为什么我的 inotifywait 循环在删除一些子目录后退出?](https://linux22.com/image/36375/%E4%B8%BA%E4%BB%80%E4%B9%88%E6%88%91%E7%9A%84%20inotifywait%20%E5%BE%AA%E7%8E%AF%E5%9C%A8%E5%88%A0%E9%99%A4%E4%B8%80%E4%BA%9B%E5%AD%90%E7%9B%AE%E5%BD%95%E5%90%8E%E9%80%80%E5%87%BA%EF%BC%9F.png)
我有以下 bash 脚本:
#!/bin/sh
dir1=/source/dir/path/
while inotifywait -qqre modify "$dir1"; do
rm -r /destination/dir/path
find /source/dir/path/ -name .svn -exec rm -rf '{}' \;
cp -ruv /source/dir/path/* /destination/dir/path/
done
问题是前两个命令运行良好,但在执行(成功)“find -exec”命令后进程被终止。有什么想法吗?
顺便说一句-如果我删除“find -exec”,一切都会顺利。
答案1
试试这个(注意!)
dir1=/source/dir/path/
while ! inotifywait -qqre modify "$dir1"; do
rm -r /destination/dir/path
find /source/dir/path/ -name .svn -exec rm -rf '{}' \;
cp -ruv /source/dir/path/* /destination/dir/path/
done