LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
LinkBack Search this Thread
Old 02-23-2006, 11:00 PM   #1
3saul
Member
 
Registered: Aug 2004
Location: Brisbane, Australia
Distribution: Ubuntu/Fedora
Posts: 85

Rep: Reputation: 15
opposite of grep


I'm wanting to match line if it doesn't equal something...

For example

ls | grep ab

Would match any file that has 'ab' in it and return it. I'm wanting to exclude any file that has a particular phrase..

Thanks
 
Old 02-23-2006, 11:02 PM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5
Posts: 16,086

Rep: Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995
ls |grep -v ab
-v switch is what you want
 
Old 04-17-2010, 04:13 AM   #3
CQ1ST
Member
 
Registered: Oct 2005
Location: NewZealand
Distribution: Crunchbang, Slitaz, Puppy
Posts: 67

Rep: Reputation: 17
and if i wanted to exclude more than one word?

ie: top |grep -v daemon +conky +firefox (excuse my googlystuff)
 
Old 04-17-2010, 04:20 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
Hi,

You can use egrep for that: ls | egrep -v "daemon|conky|firefox"

This will exclude daemon, conky and firefox from the ls listing.

Hope this helps.
 
Old 04-17-2010, 04:23 AM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 11,799

Rep: Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923
grep -E (aka egrep) - use regex rather than googlystuff.
Code:
top  -b -n 1 | grep -Ev "(daemon|conky|firefox)"
Too late - hi druuna
 
Old 04-17-2010, 04:26 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
Hi to you too syg00
 
Old 04-18-2010, 08:53 AM   #7
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 1,353

Rep: Reputation: 205Reputation: 205Reputation: 205
Or do it the uneffcient way.

$ ls | grep -v "not_this" | grep -v "or_this" | grep -v "and_not_this_too"
 
Old 04-20-2010, 08:18 PM   #8
CQ1ST
Member
 
Registered: Oct 2005
Location: NewZealand
Distribution: Crunchbang, Slitaz, Puppy
Posts: 67

Rep: Reputation: 17
______________
That's really cool, thanx heaps guys
 
Old 04-21-2010, 01:29 AM   #9
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
Hi,

@CQ1ST: Glad to see that we could be of assistance
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Netatalk opposite phatbastard Linux - Software 2 11-18-2005 04:12 AM
load(lin) -- the opposite JrLz Linux - General 2 05-09-2005 02:16 AM
what's the opposite of operator!() jhorvath Programming 5 11-02-2003 08:21 PM
Opposite to modprobe? Thymox Linux - Software 4 12-11-2002 10:40 AM
finding the opposite... PokerFace Linux - General 1 10-16-2002 08:15 AM


All times are GMT -5. The time now is 10:50 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration