Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'Sort ls output in true numerical order' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Sort ls output in true numerical order
Authored by: bdm on Jul 25, '03 09:52:22PM

The problem with
ls | sort +0.4n
is that you only see one file per line. To correct this you can pipe it through pr as well:
ls | sort +0.4n | pr -at -4
The -4 is the number of columns. -at will sort across the page. If you want sorting down the columns like ls usually does, use something like
ls | sort +0.4n | pr -tl9999 -4

The reason you see only one line per file in the original hint is that ls always does that when writing into a pipe unless you add the -C switch. However -C is no use in this application because the sorting becomes too hard.

[ Reply to This | # ]