001、
[root@PC1 test]# ls a.txt [root@PC1 test]# cat a.txt ## 测试数据 1 2 3 4 5 6 [root@PC1 test]# awk '{printf("%s ", $0)} END {printf"\n"}' a.txt 1 2 3 4 5 6 [root@PC1 test]# awk '{printf("%s ", $0)} END {printf"\n"}' a.txt | cat -A 1 2 3 4 5 6 $ [root@PC1 test]# awk '{printf("%s ", $0)} END {printf"\n"}' a.txt | sed 's/.$//' | cat -A 1 2 3 4 5 6$
002、
[root@PC1 test]# ls a.txt [root@PC1 test]# cat a.txt 1 2 3 4 5 6 [root@PC1 test]# awk 'BEGIN{RS = "$@#"}{gsub("\n", " "); print $0}' a.txt 1 2 3 4 5 6 [root@PC1 test]# awk 'BEGIN{RS = "$@#"}{gsub("\n", " "); print $0}' a.txt | sed -n l 1 2 3 4 5 6 $ [root@PC1 test]# awk 'BEGIN{RS = "$@#"}{gsub("\n", " "); print $0}' a.txt | sed 's/.$//' | sed -n l 1 2 3 4 5 6$
003、
[root@PC1 test]# ls a.txt [root@PC1 test]# cat a.txt 1 2 3 4 5 6 [root@PC1 test]# awk 'BEGIN{RS = EOF} {gsub("\n", " "); print $0}' a.txt 1 2 3 4 5 6 [root@PC1 test]# awk 'BEGIN{RS = EOF} {gsub("\n", " "); print $0}' a.txt | cat -A 1 2 3 4 5 6$
004、
[root@PC1 test]# ls a.txt [root@PC1 test]# cat a.txt 1 2 3 4 5 6 [root@PC1 test]# awk '{ORS = " "; print $0}' a.txt | sed 's/.$/\n/' 1 2 3 4 5 6 [root@PC1 test]# awk '{ORS = " "; print $0}' a.txt | sed 's/.$/\n/' | cat -A 1 2 3 4 5 6$
标签:root,PC1,cat,awk,linux,test,txt,数据 From: https://www.cnblogs.com/liujiaxin2018/p/16965759.html