I have an gz file which contains values in $12 and $33, where they contains strings (ex $12: 33-A and $33: 33A), I am trying to create an awk command that reads the values and counts the number of times "-" is in $12 but not in $13.
I have: gzcat test.gz | awk '{if ($12!=$33 && $12~/ -/ && $33!~/ -/) wc -l; else null} | wc -l'
But that command doesn't seem to work and get me the outcome I would like.
答案 0 :(得分:2)
不需要单独检查相等性,因为它暗示,并且不需要使用wc
,awk
能够计数
... | awk '$12~/-/ && $33!~/-/{count++} END{print count+0}'
PS。您的脚本不是有效的awk
脚本。字段33
或13
?