LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   opposite of grep (https://www.linuxquestions.org/questions/linux-software-2/opposite-of-grep-418958/)

3saul 02-23-2006 11:00 PM

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

chrism01 02-23-2006 11:02 PM

ls |grep -v ab
-v switch is what you want

CQ1ST 04-17-2010 04:13 AM

and if i wanted to exclude more than one word?

ie: top |grep -v daemon +conky +firefox (excuse my googlystuff)

druuna 04-17-2010 04:20 AM

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.

syg00 04-17-2010 04:23 AM

grep -E (aka egrep) - use regex rather than googlystuff.
Code:

top  -b -n 1 | grep -Ev "(daemon|conky|firefox)"
Too late - hi druuna

druuna 04-17-2010 04:26 AM

Hi to you too syg00 ;)

Shadow_7 04-18-2010 08:53 AM

Or do it the uneffcient way.

$ ls | grep -v "not_this" | grep -v "or_this" | grep -v "and_not_this_too"

CQ1ST 04-20-2010 08:18 PM

______________
That's really cool, thanx heaps guys

druuna 04-21-2010 01:29 AM

Hi,

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


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