Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Find the answer to your Linux question:
New to Linux Forums? Register here for free!
    Linux Forums > GNU Linux Zone > Linux Newbie > What command to find files that not meeting some conditions?

Forgot Password?
 Linux Newbie   If you're new to the wonderful world of Linux, start here!

Site Navigation
Linux Articles
Linux Forums
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds


Linux Forum Topics
Linux Forums
Your Distro
Linux Resources
GNU Linux Zone
The Community
Reply
 
Thread Tools Display Modes
Old 02-12-2009   #1 (permalink)
Just Joined!
 
Join Date: Feb 2009
Posts: 3
What command to find files that not meeting some conditions?

Usually, when we look for a file named, "abc.gz", the command will be:

find -name "abc.gz"

But how to find all files which is not named as "abc.gz"?
KennyP is offline  


Reply With Quote
Old 02-13-2009   #2 (permalink)
Linux Newbie
 
Join Date: Sep 2007
Posts: 129
hi kenny,

the exclamation mark "!" negates expressions. it's in the man page under "operators".

cheers, kai
kai12 is offline   Reply With Quote
Old 02-13-2009   #3 (permalink)
Just Joined!
 
Join Date: Feb 2009
Posts: 3
Quote:
Originally Posted by kai12 View Post
hi kenny,

the exclamation mark "!" negates expressions. it's in the man page under "operators".

cheers, kai
how should write the command?

I tried the following but failed.

find -!name "abc.gz"

-bash: !name: event not found

find -name !"abc.gz"

-bash: !"abc.gz": event not found

find !-name "abc.gz"

-bash: !-name: event not found
KennyP is offline   Reply With Quote
Old 02-13-2009   #4 (permalink)
Linux Newbie
 
Join Date: Sep 2007
Posts: 129
Code:
find ! -name "abc.gz"
note the blank between ! and -name
kai12 is offline   Reply With Quote
Old 02-14-2009   #5 (permalink)
Just Joined!
 
Join Date: Feb 2009
Posts: 3
Quote:
Originally Posted by kai12 View Post
Code:
find ! -name "abc.gz"
note the blank between ! and -name
It works great now, thank you so much
KennyP is offline   Reply With Quote
Old 03-05-2009   #6 (permalink)
Just Joined!
 
sathiya's Avatar
 
Join Date: Feb 2008
Location: Chennai, India
Posts: 77
Arrow

You can also use the following way for better readability.

find -not -name "abc.tgz"

The technique which you are asking is called as inverting match. You can find a lot of examples over here... Mommy, I found it! — 15 Practical Linux Find Command Examples
sathiya is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Free Magazines
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview
Learn about everything you'll need to build and maintain your Linux servers, and to deploy Web applications to them.
subscribe
Open Source Security Myths Dispelled
Dispel the five major myths surrounding Open Source Security and gain the tools necessary to make a truly informed decision for your IT organization
subscribe
InformationWeek
InformationWeek is the only newsweekly you'll need to stay on top of the latest developments in information technology.
subscribe



All times are GMT. The time now is 05:41 PM.






© 2000 - 2009 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.3.0 RC2