chovy
chovy

Reputation: 75666

remove lines matching more than one pattern using sed

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.

Upvotes: 0

Views: 150

Answers (4)

potong
potong

Reputation: 58420

This might work for you (GNU sed):

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

or:

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

Upvotes: 0

Mark Setchell
Mark Setchell

Reputation: 207465

Or with egrep:

curl <url> | egrep -v "foo|bar|baz"

Upvotes: 1

epeleg
epeleg

Reputation: 10915

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

Upvotes: 0

Jotne
Jotne

Reputation: 41456

Using awk

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

Upvotes: 0

Related Questions