Find Command

Hello I need to search for pattern in my direcotry which are not of format *.out.

I tried using ! for the not option.

The below command of mine did not work.

find . -name \!*.out -print

I also used the -not option for this and it too did not work.

find . -not \(-name *.out\) -print

Can anyone let me know of how I would use the not condition for displaying the files in my directory which are not of the format *.out

Thanks in advance for your help.

find . ! -name "*.out" -type f
1 Like
find . \! -name \*.out

That will match "." too, so be careful how you process it. You might want to do

find . -type f -a \! -name \*.out

to only find files.

1 Like

Further to malcolmpdx's valid point.

find . \( -type f -a ! -name "*.out" \) -print
1 Like

Thanks , I am now able to retreive the exact data...

Another very useful option to find is the "prune" option, for eg.

find . -name "*.out" -prune -o -print

would give the same effect.

grep -v "*.out" *