egrep

Hi,

I am wondering if it's possible to link multiple patterns with egrep.

Here here is what I am doing :

 grep -v ";;" | grep -v ARC_TIME | grep -v \* | grep -v STAS0 

Can I do all of this by invoking egrep just once ?

Thanks

That is the only way to 'AND' the patterns in grep AFAIK.
Alternative awk solution,

awk '!/;;/ && !/ARC_TIME/ && !/\*/ && !/STASO/ {print}' file
1 Like
grep -Ev ';;|ARC_TIME|\*|STAS0'
1 Like

Another way:

grep -v -e pattern_1 -e pattern_2 -e pattern_3

Here we invoke grep only once; and this is what you want.

Thanks all for your help.

Instead of using the "grep -v" I found a way by using egrep to only keep what needed.

here is how I do it

egrep '(pattern_1|pattern_2'

Thanks again for your help