Exclude directories from searching entire system
This question already has an answer here:
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)(/.*)?' ...
-not
instead of !
but it's not POSIX compliant. -wholename
is synonymous to -path
but it's not POSIX compliant. 上一篇: 如何排除隐藏文件夹被删除
下一篇: 排除搜索整个系统的目录