Consider a stream of one-word lines such as the stdout of
$ echo foo bar baz quux xyxxy thud | tr ' ' '\n' foo bar baz quux xyxxy thud
I say "one-word" to indicate there is no whitespace other than the newlines. I'd like to "columnize" the data by filling in a fixed number of fields (not single characters) per line, one row at a time. For small amounts of data, xargs does this nicely:
$ echo foo bar baz quux xyxxy thud | tr ' ' '\n' | xargs -n 2 foo bar baz quux xyxxy thud
However using xargs this way is slow. I have hundreds of gigabytes of text to process, so I would very much like my write throughput to hit the 50 MB/s or so that I know this hardware can do (the xargs above is orders of magnitude slower.)
Is there something better available in the standard toolbox? I can write something if needed but I'd prefer using a text filter that's already there.