zoukankan      html  css  js  c++  java
  • linux find 命令避开某个目录的用法prune



    如果想查找当前目录(/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 ~]$
    ————————————————
    版权声明:本文为CSDN博主「lionfun」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/imfinger/article/details/6371601

  • 相关阅读:
    资源网站
    远程服务SSH
    Samba服务配置
    练习raid5
    raid(0、1)
    NFS服务器配置(windows访问)
    LVM磁盘阵列
    ISCSI服务器配置
    Zibbix监控
    MySQL Replication配置
  • 原文地址:https://www.cnblogs.com/fqnb001/p/12624824.html
Copyright © 2011-2022 走看看