English 中文(简体)
unix find command
原标题:
  • 时间:2009-11-16 10:04:41
  •  标签:
  • unix
  • shell

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

最佳回答
find <some options> ! -name "dontfile.txt"

this should be the answer. thanks Dave.

问题回答

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" )

$ 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





相关问题
KornShell- Creating a fixed width text file

I need to create a simple fixed width text file in KornShell (ksh). My current attempt using printf to pad the string isn t working out very well. What s the shortest, cleanest way to create a fixed ...

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 ...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

Case insensitive comparison of strings in shell script

The == operator is used to compare two strings in shell script. However, I want to compare two strings ignoring case, how can it be done? Is there any standard command for this?

1. 露台式照像

在Windows XP中,没有一时出现指挥时,是否有办法操作一种灰色文字? 我常常需要把“善待”(工作)与“灰色”同起来,即使我的文字没有产出,......

热门标签