• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 342
  • Last Modified:

Pass not to the find command

How do you pass NOT to the find command.  I want to find all files within a directory that do not match (files that do not match  *.04_11_09).
and then gzip them.
0
theoradically
Asked:
theoradically
2 Solutions
 
theoradicallyAuthor Commented:
As where I would run

find . -name *.04_11_09, to find all files in the current working dir that matched *.04_11_09

I want to do a find that match all files that do not match the criteria.  Sounds simple, but I don't think the find command
does that and my scripting is poor.  I'm working on my scripting skills with this groups help.  Thank You
0
 
brettmjohnsonCommented:
Use the  -not  switch to negate the value of an expression:

find -not -name "*.04_11_09" -exec gzip {} \;


0
 
brettmjohnsonCommented:
Oops, forgot the start directory to find:

find . -not -name "*.04_11_09" -exec gzip {} \;

0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
tfewsterCommented:
-not isn't available with all versions of find; In which case, you use "!"

find . ! -name "*.04_11_09" -exec gzip {} \;
0
 
theoradicallyAuthor Commented:
Thanks helpers,

I looked in the find man pages before posting this, but did not find this until I went back looking fo how to do an "and"

     2)   ! expression
           The negation of a primary (! is the unary  not  opera-
           tor).
 
     3)  expression [-a] expression
           Concatenation  of  primaries  (the  and  operation  is
           implied by the juxtaposition of two primaries).
 
     4)  expression -o expression
           Alternation of primaries (-o is the or operator).

The -not did not work for Solaris, but I did not specify the flavor.  The ! did work.  Thanks again both of you for your quick response.  I am going to split the points.
0
 
theoradicallyAuthor Commented:
FYI,

Here is how I found multiple instances of not

find . ! -name "*.04_11_09" -a ! -name "2004_11_09" -a ! -name "04_11_9" -exec gzip {} \;
0
 
mfarnhamCommented:
find ./ -print | grep -v 04_11_09
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now