LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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
  Search this Thread
Old 02-23-2006, 11:00 PM   #1
3saul
Member
 
Registered: Aug 2004
Location: Brisbane, Australia
Distribution: Ubuntu/Fedora
Posts: 86

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
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,360

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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: Xubuntu Trusty
Posts: 77

Rep: Reputation: 18
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: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
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: 21,131

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
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: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi to you too syg00
 
Old 04-18-2010, 08:53 AM   #7
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
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: Xubuntu Trusty
Posts: 77

Rep: Reputation: 18
______________
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: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

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


Reply



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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:13 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration