The columns
tool can do this:
$ seq 10 | columns -W 16 -c 3
1 2 3
4 5 6
7 8 9
10
-W 16
is just to set the line width to something small.
columns
is not a Unix standard tool.
It is part of GNU AutoGen.
Some versions of the more common column
command may be able to set the number of columns with -c
, but modern versions seem to have changed its meaning to set the line width by number of characters.
There's also pr
as suggested by mpez0 in a comment:
$ seq 10 | pr -aT3
1 2 3
4 5 6
7 8 9
10
-aT3
is short for --across --omit-pagination --columns=3
.
pr
is in coreutils and POSIX, though -T
/--omit-pagination
seems to be GNU-specific.
awk
?