> Wow.
> Excellent us of tools.
It's the sort of thing I used to give as an exercise to students.
> The smallest arbitrary-columns answer I could come up with was:
> awk '{if(m < NF)m=NF;for(i=1;i<=NF;i++)r[NR, i]=$i}END {for(i=1;i<=m;i+
> +){for(j=1;j<=NR;j++)printf "%s ", r[j,i];print ""}}' t
Explicit looping looks so strenuous.
To make the tr|pr method more general, you can count columns first with
sed 1q | wc -b
or if you like
awk '{print NF;exit}'
Counting rows is left as an exercise to the reader ...