unix find命令

时间:2009-11-16 10:04:41

标签: unix shell

如何使用find命令查找与模式不匹配的文件/目录。 例如:

find <some options > -name "dontfile.txt"

应该为我提供所有文件名不是dontfile.txt

的查找的输出

3 个答案:

答案 0 :(得分:3)

使用-not运算符:

find <some options > -not -name "dontfile.txt"

您可能需要添加括号以获得所需的效果,具体取决于命令的其余部分的复杂程度:

find <some options > \( -not -name "dontfile.txt" \)

答案 1 :(得分:2)

find <some options> ! -name "dontfile.txt"

这应该是答案。 谢谢戴夫。

答案 2 :(得分:-2)

$ ls -ltr

总计0

-rw-r - r-- 1 mraj baudba 0 Nov 18 05:35 d.txt

-rw-r - r-- 1 mraj baudba 0月18日05:35 c.txt

-rw-r - r-- 1 mraj baudba 0月18日05:35 b.txt

-rw-r - r-- 1 mraj baudba 0月18日05:35 a.txt

$ find。 -name“a.txt”-print

./ A.TXT

$ find。 ! -name“a.txt”-print

./ b.txt

./ c.txt

./ d.txt

$

Unix find command with examples