bobylapointe
bobylapointe

Reputation: 683

AWK: print only lines not matching the defined pattern

I'd like to make AWK only print lines that don't match the following pattern: awk -F'-' 'NF>7'
(lines in which - appears more than 7times)

Is there a simple way to do this?

Thank you very much

Upvotes: 0

Views: 1462

Answers (2)

Ed Morton
Ed Morton

Reputation: 204638

Stick a ! in front of it or change the comparison from > to <=.

Upvotes: 3

karthik006
karthik006

Reputation: 951

If you're not tied to using Awk, GNU Grep can do it: Code:

grep -Ev '<your regex>'

The -v option means show lines that don't match, -E means use extended regular expressions

Upvotes: 0

Related Questions