我写一个shellscript里,它删除所有的发现。???文件夹及其内容。我写这样的:
I am writing a ShellScript that deletes every found.??? folders with its contents. I wrote this:
find $DRIVE -name 'found.???' -type d -exec rm -r {} \;据我想要做什么,但给这个错误:
It does what I want, but gives this error:
find: „/media/.../found.000": No such file or directory find: „/media/.../found.001": No such file or directory我能做些什么呢?谢谢!
What can I do with this? Thanks!
推荐答案这是不是一个真正的问题。 找到是要pre-过程中的一些成果,当它试图删除一些目录已经被删除,你会得到标准错误。
This isn't really an issue. find is going to pre-process some results and when it tries to delete some directories which have already been deleted, you will get the stderr.
您可以忽略该错误消息,使用 -depth ,使其在DFS遍历,或迫使它 -prune 的目录。即
You can either ignore the error messages, use -depth to make it traverse in DFS, or force it to -prune the directories. i.e.
find "$DRIVE" -mindepth 1 -depth -name 'found.???' -type d -exec rm -r {} \;或
find "$DRIVE" -mindepth 1 -name 'found.???' -type d -prune -exec rm -r {} \;的注意, mindepth 1 ,所以你不小心删除$ DRIVE是很重要的
Note, mindepth 1 is important so you don't accidentally delete "$DRIVE"
更多推荐
与所有的UNIX下使用find其内容删除目录
发布评论