1.if else
[root@node01 awk]# cat 1.log |awk '{if($0~/AA/){print $0" YES"}else{print $0" NO YES"}}'
AA YES
BC NO YES
AA YES
CB NO YES
CC NO YES
AA YES
NO YES
[root@node01 awk]# cat 1.log
AA
BC
AA
CB
CC
AA
2.next 跳过后面的代码
[root@node01 awk]# cat 1.log |awk '/AA/{print $0" YES";next}{print $0" NO YES"}'
AA YES
BC NO YES
AA YES
CB NO YES
CC NO YES
AA YES
NO YES
[root@node01 awk]# cat 1.log |awk '/AA/{print $0" YES"}!/AA/{print $0" NO YES"}'
AA YES
BC NO YES
AA YES
CB NO YES
CC NO YES
AA YES
NO YES
3.