How do I columnate a list of items with minimal width?

Thanks @rubo77 for asking this, it's a great exercise. For me it was to off-by-one errors what English is Tough Stuff is to botched rhythm: it got fun, fast, even though the algorithm itself here is pretty simple.

[ final edit: moved to https://github.com/jthill/columnate/blob/master/columnate, bug fixed, row-major implemented. ]


Something close to the output of ls:

for i in *; do echo -en "${i}\t"; done; echo

Tags:

Bash

Ls