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.

chovy
  • 72,281
  • 52
  • 227
  • 295

4 Answers4

1

Or with egrep:

curl <url> | egrep -v "foo|bar|baz"
Mark Setchell
  • 191,897
  • 31
  • 273
  • 432
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

epeleg
  • 10,347
  • 17
  • 101
  • 151
  • 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. – chovy Feb 20 '14 at 08:04
  • you might find some of the things here http://stackoverflow.com/questions/5410757/sed-delete-a-line-containing-a-specific-string helpfull. – epeleg Feb 20 '14 at 08:09
0

Using awk

curl <url> | awk '!/foo|bar|baz/'
Jotne
  • 40,548
  • 12
  • 51
  • 55
0

This might work for you (GNU sed):

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

or:

sed '/foo/!b;/bar/!b;/baz/d' file
potong
  • 55,640
  • 6
  • 51
  • 83