linux系统中将矩形数据转换为一行、一列的形式

1、测试数据

[root@centos79 test]# cat a.txt
e t c i w
s g g d z
c i o n m

 

2、转换为一行

[root@centos79 test]# cat a.txt
e t c i w
s g g d z
c i o n m
[root@centos79 test]# awk '{ORS = " "}{print $0} END {printf "\n"}' a.txt
e t c i w s g g d z c i o n m

 

3、转换为一列

[root@centos79 test]# cat a.txt
e t c i w
s g g d z
c i o n m
[root@centos79 test]# tr " " "\n" < a.txt
e
t
c
i
w
s
g
g
d
z
c
i
o
n
m

 

posted @ 2021-07-25 23:36  小鲨鱼2018  阅读(95)  评论(0编辑  收藏  举报