How exclude files / folders for remove
This question already has an answer here:
注意:小心运行以下命令。
find . -type 'f' | grep -v "NameToExclude" | xargs rm
find . -type 'd' | grep -v "NameToExclude" | xargs rmdir
The rm function does not have an exclude function. Instead you can use rm *.txt
to delete only text files, rm *.pdf
to delete only PDF files, rm a*
to delete only files starting with the letter a, rm *d
to delete only files ending with the letter d, etc.
Using this method, you can relatively quickly delete all the files except the ones you don't want to.
链接地址: http://www.djcxy.com/p/78120.html上一篇: 从find linux中排除一个目录
下一篇: 如何排除要删除的文件/文件夹