1、测试数据
[root@centos79 test]# cat a.txt 3 s g a e f k n y
2、xargs
[root@centos79 test]# cat a.txt 3 s g a e f k n y [root@centos79 test]# cat a.txt | xargs -n 1 3 s g a e f k n y
3、sed
[root@centos79 test]# cat a.txt 3 s g a e f k n y [root@centos79 test]# cat a.txt | sed 's/ /\n/g' 3 s g a e f k n y
4、tr
[root@centos79 test]# cat a.txt 3 s g a e f k n y [root@centos79 test]# cat a.txt | tr " " "\n" 3 s g a e f k n y
5、awk
[root@centos79 test]# cat a.txt 3 s g a e f k n y [root@centos79 test]# awk '{gsub(" ", "\n"); print}' a.txt 3 s g a e f k n y
6、awk
[root@centos79 test]# cat a.txt 3 s g a e f k n y [root@centos79 test]# awk '{for(i = 1; i <= NF; i++){printf("%s\n", $i)}}' a.txt 3 s g a e f k n y
7、awk
[root@centos79 test]# cat a.txt 3 s g a e f k n y [root@centos79 test]# awk 'BEGIN{RS = " "; ORS = "\n"} {print}' a.txt 3 s g a e f k n y [root@centos79 test]# awk 'BEGIN{RS = " "; ORS = "\n"} {print}' a.txt | sed '$d' 3 s g a e f k n y