Reputation: 61
grep "<ValidateXYZResponse" filename.log* | grep -v "<ResponseCode>000<ResponseCode>"
Above command works fine in UNIX where grep -v excludes the records having response code "000"
However, along with "000", I need to exclude the following response codes too: "404", "410", "403", "406"
I am new to unix shell script.
If anyone knows how to do it, please help. Appreciate your help. Thanks.
Upvotes: 0
Views: 62
Reputation: 195059
you can do (foo|bar|blah)
to implement OR
in regex. Like:
grep ...|grep -v '<...>\(000\|40[346]\|410\)<...>'
or
grep ...|grep -vE '<...>(000|40[346]|410)<...>'
detailed explanation about regex-alternation:
http://www.regular-expressions.info/alternation.html
Upvotes: 3
Reputation: 41838
grep "<ValidateXYZResponse" filename.log* | grep -Pv "<ResponseCode>(?:000|40[346]|410)<ResponseCode>"
(?:000|40[346]|410)
non-capturing group in the middle gives a list of codes to exclude|
is the alternation (OR) operator[346]
means one character that is either 3
, 4
or 6
Upvotes: 1