Posts: 178 | Thanked: 91 times | Joined on May 2011 @ Mira (Venice) - Italy
#1
With grep how can I use multiple "pattern"?

Exemple:

I need all the nokia-maps and rss packages so I use...

dpkg -l | grep nokia-maps

... and ...

dpkg -l | grep rss

Is there a way to do it in a single instruction?

Sorry for my bad english I'm italian
 
coredumb's Avatar
Posts: 92 | Thanked: 74 times | Joined on Nov 2008 @ Indonesia
#2
Originally Posted by Vento View Post
With grep how can I use multiple "pattern"?

Exemple:

I need all the nokia-maps and rss packages so I use...

dpkg -l | grep nokia-maps

... and ...

dpkg -l | grep rss

Is there a way to do it in a single instruction?

Sorry for my bad english I'm italian
use parameter '-E'

dpkg -l | grep -E "nokia-maps|rss"
 

The Following 6 Users Say Thank You to coredumb For This Useful Post:
Posts: 178 | Thanked: 91 times | Joined on May 2011 @ Mira (Venice) - Italy
#3
ThanksThanksThanksThanksThanksThanks
 
Posts: 2,802 | Thanked: 4,490 times | Joined on Nov 2007
#4
Alternatively you can type "egrep" instead of "grep -E" (same thing, saves some typing).

Last edited by lma; 2011-08-11 at 21:47.
 

The Following 2 Users Say Thank You to lma For This Useful Post:
shallimus's Avatar
Posts: 568 | Thanked: 969 times | Joined on Dec 2009 @ Toronto
#5
This is just the beginning of what you can do with egrep.

Regular expressions are very powerful. The | means OR.

You could also search for only those lines which end with the word 'driver' OR contain the word 'editor' followed by at least two 2 numbers:
Code:
dpkg -l | grep -E "driver|wl[0-9][0-9]"
The possibilities are endless. See google for more information on basic regular expressions...
__________________
tinfoilhat.dll: Trojan horse detected
Sailfish want list: calendar bugfixes, glanceable agenda, Swype or similar
Evolution continues (but we're still pre-Cambrian)

 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 11:14.