AWK:列号长度 [英] Awk: Length of column number

查看:527
本文介绍了AWK:列号长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个(可能)愚蠢的问题。

I have a (maybe) silly question.

我的数据:
文件1

My data: File 1

1234.34  a 1235.34 d
3456.23  b 3457.23 e
2325.89  c 2327.89 f 

我想是这样

awk '{if($1==$3) print $4}'

但是,当然,如果我这样做,将打印什么。因此,我希望修改的$ 3(在这种情况下)的precision

But of course if I do this, it will print nothing. So I want to modify the "precision" of $3 (in this case)

在这个意义上,当AWK读取$ 3中发现这一点:

in the sense that when awk read $3 it finds this:

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}'

帮助?

推荐答案

您可以计算出两个值的区别:

You could calculate the difference of the two values:

awk '$1 - $3 < 0.01 || $3 - $1 < 0.01 {print $4}' file

这篇关于AWK:列号长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆