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.
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:
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.