本文介绍了在UNIX中将行转置为列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有下面给出的输入文件
I have input file which is given below
输入文件
10,9:11/61432568509
118,1:/20130810014023
46,440:4/GTEL
10,9:11/61432568509
118,1:/20130810014023
46,440:4/GTEL
我正在寻找的输出.
10,9:11/61432568509,118,1:/20130810014023,46,440:4/GTEL
10,9:11/61432568509,118,1:/20130810014023,46,440:4/GTEL
我已经尝试使用awk命令,但是没有得到想要的输出.有人可以帮我吗?
I have tried with awk command, but i am not getting desired output. can anyone help me in this?
awk -F"" '{a[$1]=a[$1]FS$2}END{for(i in a) print i,a[i]}' inputfile
推荐答案
使用awk
:
$ awk 'ORS=(NR%3==0)?"\n":","' inputfile
10,9:11/61432568509,118,1:/20130810014023,46,440:4/GTEL
10,9:11/61432568509,118,1:/20130810014023,46,440:4/GTEL
$ awk 'ORS=(NR%3?",":RS)' inputfile
10,9:11/61432568509,118,1:/20130810014023,46,440:4/GTEL
10,9:11/61432568509,118,1:/20130810014023,46,440:4/GTEL
这篇关于在UNIX中将行转置为列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!