Topic: grep

Someone was looking for an "AND" grep.

Is that what you wanted unknown person ? big_smile

# grep for AAA and BBB and CCC (in any order)
sed '/AAA/!d; /BBB/!d; /CCC/!d'

# grep for AAA and BBB and CCC (in that order)
sed '/AAA.*BBB.*CCC/!d'

# grep for AAA or BBB or CCC (emulates "egrep")
sed -e '/AAA/b' -e '/BBB/b' -e '/CCC/b' -e d    # most seds
gsed '/AAA\|BBB\|CCC/!d'                        # GNU sed only

# print paragraph if it contains AAA (blank lines separate paragraphs)
# HHsed v1.5 must insert a 'G;' after 'x;' in the next 3 scripts below
sed -e '/./{H;$!d;}' -e 'x;/AAA/!d;'

# print paragraph if it contains AAA and BBB and CCC (in any order)
sed -e '/./{H;$!d;}' -e 'x;/AAA/!d;/BBB/!d;/CCC/!d'

# print paragraph if it contains AAA or BBB or CCC
sed -e '/./{H;$!d;}' -e 'x;/AAA/b' -e '/BBB/b' -e '/CCC/b' -e d
gsed '/./{H;$!d;};x;/AAA\|BBB\|CCC/b;d'         # GNU sed only

<wintellect> NetBSD users are smart enough to accept that there's no 3D support tongue

Re: grep

This could be in the RTFM section wink

"UBER" means I don't drink the coffee... I chew the beans instead
             -- Copyright BSDnexus

Re: grep

Might have been my post, awhile back, when I just asked people what their method was for grepping multiple patterns.  In my case, it was idle curiosity, as there are different ways to do it (for example, in FreeBSD one can type egrep or grep -E. 

Hey, in case it was me can I change from Mr. Nice Guy to Unknown Person?

<@andre> i would be so much more efficient if i wasn't so stupid

Re: grep

I think it was you smile

Want someone to change the text ? big_smile

(I'm moving this thread to RTFM)

<wintellect> NetBSD users are smart enough to accept that there's no 3D support tongue

Re: grep

dynek wrote:

I think it was you smile

Want someone to change the text ? big_smile

Yes please

Let me find the old thread of mine....



http://forums.bsdnexus.com/viewtopic.php?id=471

Is that the thread you meant?

<@andre> i would be so much more efficient if i wasn't so stupid

Re: grep

Yes!

I'm so tired I thought we had this chat on irc big_smile

<wintellect> NetBSD users are smart enough to accept that there's no 3D support tongue

Re: grep

I see my rank has changed.  Thank you.  smile

<@andre> i would be so much more efficient if i wasn't so stupid

Re: grep

you said it, dirty smile

<wintellect> NetBSD users are smart enough to accept that there's no 3D support tongue