awk 实现列转行例子(收藏下)
[/tmp/test]# cat tt3
1 2 3 4 5 6 7
2 3 4 5 6 7 1
3 4 5 6 7 1 2
4 5 6 7 1 2 3
5 6 7 1 2 3 4
[/tmp/test]# awk '{maxnf=NF;maxnr=NR;for(i=1;i<=NF;i++) a[NR,i]=$i}END{for(i=1;i<=maxnf;i++){for(j=maxnr;j>=0;j--) printf a[j,i]" ";printf "\n"}}' tt3
5 4 3 2 1
6 5 4 3 2
7 6 5 4 3
1 7 6 5 4
2 1 7 6 5
3 2 1 7 6
4 3 2 1 7
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/24237320/viewspace-2095365/
,如需转载,请注明出处,否则将追究法律责任。