开发者

unix find command

how to use the find command to find files/directories which are not matching the pattern. for eg:

开发者_运维技巧find <some options > -name "dontfile.txt"

should give me output of all the find whose file name is not dontfile.txt


Use the -not operator:

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

You may need to add parenthesis to get the desired effect, depending on how complex the rest of the command is:

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


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

this should be the answer. thanks Dave.


$ ls -ltr

total 0

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

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

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

-rw-r--r-- 1 mraj baudba 0 Nov 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜