当前位置: 动力学知识库 > 问答 > 编程问答 >

Using greater than in awk ( >) to compare two fields

问题描述:

I'm trying to do something like

awk '/$2>$1/{print}'

But I'm getting no results,almost all of the second field though should be greater than the first field

网友答案:

Comment by @kevin is correct: the / delimiters make the comparison a regular expression.

Given input

1 2
2 3
2 1
3 2
3 1

this

awk '$2>$1{print}'

gives

1 2
2 3
分享给朋友:
您可能感兴趣的文章:
随机阅读: