将行重击到列 [英] Bash rows to column
本文介绍了将行重击到列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道如何将文件中的行转置为列,但是我想将文件下半部分的行追加到上半部分的行.
I know how to transpose rows in a file to columns, but I want to append the lines of the bottom half of a file to the lines to the upper half.
赞:
A1
A2
A3
B1
B2
B3
到
A1 | B1
A2 | B2
A3 | B3
该列表来自两个grep
.我在第一个grep
后面附加第二个.这两个grep
具有相同的点击量.
the list comes from two grep
s. I append the first grep
with the second one. The two grep
s have the same amount of hits.
我想在bash脚本中执行此操作.
I want to do this within a bash script.
推荐答案
$ awk '{a[NR]=$0} END{ m=NR/2; for (i=1;i<=m;i++) print a[i] " | " a[i+m]}' file
A1 | B1
A2 | B2
A3 | B3
这篇关于将行重击到列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文