0

I'm trying to remove a few lines matching some regex.

curl <url> | sed '/\(foo\|bar\|baz\)/d'

i don't want any of those lines to show that match foo, bar or baz

it stops on foo

if this is easier with awk, i'm ok with that.

2
  • Do you mean "i don't want any of those lines to show that match foo, bar and baz"? Commented Feb 20, 2014 at 9:50
  • your sed works fine in my env (CGYWIN) Commented Feb 20, 2014 at 11:57

4 Answers 4

1

Or with egrep:

curl <url> | egrep -v "foo|bar|baz"
Sign up to request clarification or add additional context in comments.

Comments

0

Using awk

curl <url> | awk '!/foo|bar|baz/'

Comments

0

try

curl <url> | sed '/foo\|bar\|baz/d'

also see many many close examples here: http://www.theunixschool.com/2012/06/sed-25-examples-to-delete-line-or.html

2 Comments

it actually works as expect. the docs say that it stops at first matching regex. i need to make it greedy, but /g did not work.
you might find some of the things here stackoverflow.com/questions/5410757/… helpfull.
0

This might work for you (GNU sed):

sed '/foo/{/bar/{/baz/d}}' file

or:

sed '/foo/!b;/bar/!b;/baz/d' file

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.