假设我有一个像这样的目录结构
mkdir -p test/1
mkdir -p test/2
mkdir -p test/3
touch test/1/touch
touch test/2/touch
touch test/3/touch
如何查找test/
中的所有文件,test/2
中的文件除外?
答案 0 :(得分:3)
使用-prune
:
find test -path 'test/2' -prune -or -print
答案 1 :(得分:1)
搜索时有一些good examples here目录排除。
答案 2 :(得分:1)
您可以这样使用-not
:
find -not -wholename './test/2*'
答案 3 :(得分:1)
另一个简短查找变体是:
find test ! -path "test/2*"
<强>输出强>
test
test/1
test/1/touch
test/3
test/3/touch