如何查找与模式匹配的每个文件和目录,但不使用来查找一个目录find?
说我有以下文件结构;
。
foo-exclude-me /
foo.txt
foo-exclude-me-not /
foo.txt
酒吧/
foo.txt
foobar /
bar.txt
foofoo.txt
我将如何使用以下输出find:
./bar/foo.txt ./bar/foobar ./bar/foobar/foofoo.txt ./foo-exclude-me-not ./foo-exclude-me-not/foo.txt
我尝试使用以下两个命令:
找 。-name'foo-exclude-me'-修剪-o -name'foo *' 找 。-name'foo *'\!-path'./foo-exclude-me/*'
但是他们两个都返回此:
./bar/foo.txt
./bar/foobar
./bar/foobar/foofoo.txt
./foo-exclude-me # << this should be excluded
./foo-exclude-me-not
./foo-exclude-me-not/foo.txt
如何正确排除foo-exclude-me目录?
@MaxMackie完美:)
—
Tyilo
它固定了吗?哪种解决方法对您有用?我可以将其放在答案中而不是评论中。
—
13年
@MaxMackie同时使用
—
Tyilo 2013年
-print和foo-exclude-me而不是./foo-exclude-me。
foo-exclude-me代替./foo-exclude-me。也可以尝试-print在命令末尾附加。