You're viewing a comment by Peter Krumins and its responses.

June 27, 2012, 19:27

Your reasoning is correct, and your program is actually correct.

The only problem is with the type of regular expressions sed uses. It uses so called "basic" regexes where | is an ordinary character.

You've to escape it to make it work like an alternation operator:

sed -e '/AAA\|BBB/!d;/CCC/!d'

Try this and it will work.

Also check out the -r argument to sed. It enables extended regular expressions, and your program will work:

sed -re '/AAA|BBB/!d;/CCC/!d'

Comment Responses

Human Permalink
July 25, 2012, 09:09

Thankyou Peter. Both your suggestions worked.

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "unix_95": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.