|
|
Subscribe / Log in / New account

Leading spaces are common, actually

Leading spaces are common, actually

Posted Mar 28, 2009 1:57 UTC (Sat) by foom (subscriber, #14868)
In reply to: Leading spaces are common, actually by nix
Parent article: Wheeler: Fixing Unix/Linux/POSIX Filenames

> Sorting numerically in GNU ls is done by 'ls -v'.

Huh, never knew that, interesting! Never would have found that from the man page, which says "-v sort by version". That seems a remarkably poor description of what it actually does.

> (By default, despite comments elsewhere in this thread, ls sorts ASCIIbetically, so " 2" comes before "1".)

Well, not exactly: GNU ls has a default sort which depends on the locale's collation settings, and most systems default to a locale like en_US.UTF-8, so most people have it sorting in a case/accent-insensitive manner by default on their systems.


to post comments

Leading spaces are common, actually

Posted Mar 28, 2009 20:36 UTC (Sat) by nix (subscriber, #2304) [Link]

It's called 'sort by version' because the function it calls (strverscmp())
was designed to sort version numbers, and because the expected use of
ls -v was sorting a directory full of version-named directories in version
order.

(And you're right on the collation sort thing: I spoke carelessly.)


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds