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 "
"}' 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 " " "
" < a.txt
e
t
c
i
w
s
g
g
d
z
c
i
o
n
m
原文地址:https://www.cnblogs.com/liujiaxin2018/p/15059468.html