如何搭配两条线和减去它们 [英] how to match two lines and subtract them
本文介绍了如何搭配两条线和减去它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个文件有两个专栏中,我想,如果他们是从列匹配减去柱之一,在两列的每一个值匹配两栏一栏的两个匹配值之一
0 7.788244
7.800744 1
7.813244 2
7.825744 3
7.838244 4
7.850744 5
7.863244 6
7.875744 7
7.888244 8
7.900744 9
7.913244 10
7.925744 11
7.938244 12
7.950744 13
7.963244 14
7.975744 15
7.801751 0
7.814251 1
7.826751 2
7.839251 3
7.851751 4
7.864251 5
7.876751 6
7.889251 7
7.901751 8
7.914251 9
7.926751 10
7.939251 11
7.951751 12
7.964251 13
7.976751 14
7.989251 15
例如
0.013507
0.013507
0.013507
解决方案
您可以这样做:
的awk'{a [$ 2] B〔++ i] = $ 1-A [$ 2]:A [$ 2] = $ 1} END {为(X - LT;长度( b);)打印b〔++ X]}'INPUTFILE
I have one file with two column , I want to match column two with every value in column two if they are matched subtract column one from column one of the two matched value of column one
7.788244 0
7.800744 1
7.813244 2
7.825744 3
7.838244 4
7.850744 5
7.863244 6
7.875744 7
7.888244 8
7.900744 9
7.913244 10
7.925744 11
7.938244 12
7.950744 13
7.963244 14
7.975744 15
7.801751 0
7.814251 1
7.826751 2
7.839251 3
7.851751 4
7.864251 5
7.876751 6
7.889251 7
7.901751 8
7.914251 9
7.926751 10
7.939251 11
7.951751 12
7.964251 13
7.976751 14
7.989251 15
example
0.013507
0.013507
0.013507
解决方案
You can do something like:
awk '{a[$2]?b[++i]=$1-a[$2]:a[$2]=$1}END{for(;x<length(b);) print b[++x]}' inputFile
这篇关于如何搭配两条线和减去它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文