I'm trying to take some single column data and display it in a tty as columns, much like
ls does. Basically, you can think of this as trying to take the output from
ls -1 and make it look like the normal output of
ls, where the number of columns and the space given to each column is optimized.
The column command can't easily be coerced into taking up a certain width, and the
pr utility doesn't dynamically change the number of columns.
With all the text parsing commands available, I just can't believe there isn't some way to make this happen out of the box.
This would be a fairly complex little shell script, because in order to calculate the optimal column width you need to know how many items will be in your column (to calculate the length of the longest item), which you don't know until you figure out how many columns there will be, which depends on the width of each column. Because of the circular reasoning, it seems like iterative refinement is the only way to go. Not hard, but not a one-liner either. A built-in would be a much better solution if it exists.