shell如何按指定行数分割成多列


有文件1.txt
1
2
3
4
5
6
7
...
如何分割成3行多列:
1 4 7
2 5
3 6

awk shell

上白泽蘑菇碳 12 years, 3 months ago

seq 1 20|awk 'BEGIN{i=1;}{ if(!(i%3)){a[i]=a[i]" "$0;i=1;}else{a[i]=a[i]" "$0;i++;}}END{for(t in a)print a[t]}'

带把美G answered 12 years, 3 months ago

Your Answer