linux find 命令避开某个目录的用法prune

来源:互联网 发布:购物分享php系统 编辑:程序博客网 时间:2024/05/21 07:13

如果想查找当前目录(/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 ~]$


转自: http://blog.csdn.net/imfinger/article/details/6371601

0 0
原创粉丝点击