我正在尝试列出所有.hpp
个文件,但是那些路径包含单词的文件,
例如:
find -name '*.hpp'
会给出
folder1/folder2/something.hpp
folder1/folder3/something.hpp
folder1/folder4/something.hpp
我想排除folder2中的文件,以便只包含以下内容:
folder1/folder3/something.hpp
folder1/folder4/something.hpp
答案 0 :(得分:3)
只是否定-path
条件:
find -name '*.hpp' -not -path '*/folder2/*'
要排除多个目录,请重复以下条件:
find -name '*.hpp' -not -path '*/folder2/*' -not -path '*/folder3/*'
或者在正则表达式中使用替代方法:
find -name '*.hpp' -not -regex '.*/\(folder2\|folder3\)/.*'