[英]Awk: Length of column number
I have a (maybe) silly question. 我有一个(也许)愚蠢的问题。
My data: File 1 我的数据:文件1
1234.34 a 1235.34 d
3456.23 b 3457.23 e
2325.89 c 2327.89 f
I want something like 我想要类似的东西
awk '{if($1==$3) print $4}'
But of course if I do this, it will print nothing. 但是,当然,如果执行此操作,它将不会打印任何内容。 So I want to modify the "precision" of $3 (in this case) 所以我想修改$ 3的“精度”(在这种情况下)
in the sense that when awk read $3 it finds this: 在某种意义上,当awk读取$ 3时,它会发现:
124
345
232
then it must be a way to do this, but I don't know it. 那么这一定是做到这一点的一种方法,但我不知道。
awk '{if($1==(three digits precision $3)) print $4}'
Help? 救命?
您可以计算两个值的差:
awk '$1 - $3 < 0.01 || $3 - $1 < 0.01 {print $4}' file
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.