Exclude directories from searching entire system

This question already has an answer here:

  • How to exclude a directory in find . command 32 answers

  • You can add conditions that would exclude directories:

    find . '!' -path './dir1/*' '!' -path './dir2/*' ...
    

    To be more precise also exclude the directory themselves:

    find . '!' -path './dir1' '!' -path './dir2' '!' -path './dir1/*' '!' -path './dir2/*' ...
    

    You can also use regex:

    find . -regextype posix-extended -not -regex '[.]/dir(1|2)(/.*)?' ...
    
  • You can also use -not instead of ! but it's not POSIX compliant.
  • -wholename is synonymous to -path but it's not POSIX compliant.
  • 链接地址: http://www.djcxy.com/p/78130.html

    上一篇: 如何排除隐藏文件夹被删除

    下一篇: 排除搜索整个系统的目录