行转列(awk):
awk -F "+" '{for(i=1;i<=NF;i++) a[i,NR]=$i}END{for(i=1;i<=NF;i++) {for(j=1;j<=NR;j++) printf a[i,j] " ";print ""}}' file.txt
列转行(tr):
cat file.txt |tr "\n" ","|sed -e 's/,$/\n/'
本文转自leonardos51CTO博客,原文链接:http://blog.51cto.com/leomars/1906901 ,如需转载请自行联系原作者