I have multi-column data that I wish to reformat such that each column follow "on top" of each other in one single column.
Example input:
1 2 3 4
1 2 3 4
Desired output: (fixed old typo where a "1" and a "3" was missing)
1
1
2
2
3
3
4
4
(Occasionally I would like to add spaces between the columns too)
Edit: The comment about "spaces between" was unclear. I sometimes want an empty line between the stacked columns. Adapting the Ed Morton's accepted answer below, this could be achieved by
awk '
{for (i=1; i<=NF; i++) a[i]=a[i] $i ORS}
END {for (i=1; i<=NF; i++) printf "%s", a[i](i==NF?"":"\n")}
' file
tr. But your request is unclear.