当前位置: 技术问答>linux和unix
小问题:关于cat后如何合并2个字段?
来源: 互联网 发布时间:2016-09-11
本文导语: 有一个文件a.info Capacity: 0.01%, Priority: LEVEL5Running Jobs: 0, Waiting Jobs:0 queueName=a Capacity: 0.01%, Priority: LEVEL5Running Jobs: 0, Waiting Jobs:8 queueName=b Capacity: 0.01%, Priority: LEVEL5Running Jobs: 0, Waiting Jobs:0 queueName=c Capacity...
有一个文件a.info
Capacity: 0.01%, Priority: LEVEL5Running Jobs: 0, Waiting Jobs:0 queueName=a
Capacity: 0.01%, Priority: LEVEL5Running Jobs: 0, Waiting Jobs:8 queueName=b
Capacity: 0.01%, Priority: LEVEL5Running Jobs: 0, Waiting Jobs:0 queueName=c
Capacity: 0.01%, Priority: LEVEL5Running Jobs: 0, Waiting Jobs:6 queueName=d
我通过cut 分别得到了 第一列 0 8 0 6
第二列 a b c d
shell中显示为:
#0
8
0
6
a
b
c
d
如何合并为 a 0
b 8
c 0
d 6
啊 谢谢了
Capacity: 0.01%, Priority: LEVEL5Running Jobs: 0, Waiting Jobs:0 queueName=a
Capacity: 0.01%, Priority: LEVEL5Running Jobs: 0, Waiting Jobs:8 queueName=b
Capacity: 0.01%, Priority: LEVEL5Running Jobs: 0, Waiting Jobs:0 queueName=c
Capacity: 0.01%, Priority: LEVEL5Running Jobs: 0, Waiting Jobs:6 queueName=d
我通过cut 分别得到了 第一列 0 8 0 6
第二列 a b c d
shell中显示为:
#0
8
0
6
a
b
c
d
如何合并为 a 0
b 8
c 0
d 6
啊 谢谢了
|
|
sed 's/.*:([0-9]{1}) .*=([a-z]{1})/1 2/'
awk '{gsub(/.*:/,"",$(NF-1));gsub(/.*=/,"",$NF);print $(NF-1),$NF}’
|
cut -b 64,76 --output-delimiter=' ' info.a
|
好象只用这个符合楼主的