awk command that compares strings for difference

时间:2017-06-12 16:57:21

标签: string awk

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.

1 个答案:

答案 0 :(得分:2)

不需要单独检查相等性,因为它暗示,并且不需要使用wcawk能够计数

... | awk '$12~/-/ && $33!~/-/{count++} END{print count+0}'

PS。您的脚本不是有效的awk脚本。字段3313

也是字段
相关问题