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
  • 65,853
  • 48
  • 201
  • 247

4 Answers4

1

Or with egrep:

curl <url> | egrep -v "foo|bar|baz"
Mark Setchell
  • 169,892
  • 24
  • 238
  • 370
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
  • 9,883
  • 16
  • 98
  • 149
  • 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
  • 39,326
  • 11
  • 49
  • 54
0

This might work for you (GNU sed):

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

or:

sed '/foo/!b;/bar/!b;/baz/d' file
potong
  • 51,370
  • 6
  • 49
  • 80