awk achieve "do not print"
I would like to delete lines match specific pattern. How can I do something like:
Code:
How could I do this? Many thanks!!! |
Use the next command, which stops processing of the current line. Follow that with a pattern-action statement with an empty pattern section (matches all lines) and an action that is simply "print".
Code:
awk '$1 ~ "AA" && $4 !~ "BB" {next} {print}' |
It should work to negate the expression, either completely or:
Code:
$ awk '$1 !~ "AA" || $4 ~ "BB"' |
I think Reuti is on the right path but shouldn't it be && and not ||, ie. you want both things to be true don't you?
|
boolean algebra
Quote:
Code:
rknichols: Code:
(!a) || b -> print |
By the way, the backticks in the OP example would be read as a command substitution. Be careful not to confuse them with regular single quotes.
http://mywiki.wooledge.org/Quotes And of course $(..) is highly recommended over `..` for command substitution anyway. |
Quote:
|
Hi,
crts explained exactly what I had in mind by using rules to simplify the expression. I get: Code:
$ cat file |
Quote:
Now I understand, it is a really logic problem. Thanks a lot for your detailed and clear explanation crts!!Really helpful!! |
Quote:
|
All times are GMT -5. The time now is 06:06 PM. |