如果想查找当前目录(/home/student)下的tmp.txt文件,但是想要避开sep目录:
find /home/student -path /home/student/sep -prune -o -name "tmp.txt" -print
sep后面不能加/ 即/home/student/sep/是错误的 如果当前目录为/home/student 也可以这样
find . -path ./sep -prune -o -name "tmp.txt" -print
总结:-path 只是匹配find出来的路径,可以通过使用匹配符号* [] ?等 例如:
[student@bioeng ~]$ find . -name file
./file
./dir/file
./dir/dir555/file
./dir/dir2/file
./dir/dir1/file
[student@bioeng ~]$
[student@bioeng ~]$ find . -path "*dir[12]" -prune -o -name file -print
./file
./dir/file
./dir/dir555/file
[student@bioeng ~]$ [student@bioeng ~]$ find . -path "*dir*" -prune -o -name file -print
./file
[student@bioeng ~]$