如何比较同一文件中的两列?

问题描述 投票:0回答:1

我的数据文件很长,file.txt

1 3  
3 2  
2 3  
5 5  
8 9  

所以输出文件应该是out.txt

1 3  
1 2  
1 5   
1 9  
3 3  
3 2  
3 5 
shell awk
1个回答
0
投票

您能不能尝试以下操作。

awk 'FNR==NR{a[++count]=$2;next} {for(i=1;i<=count;i++){print $1,a[i]}}' Input_file Input_file
© www.soinside.com 2019 - 2024. All rights reserved.