Next: Special handling of file extensions, Previous: Minus/Hyphen and Colon characters, Up: Differences from the official Debian Algorithm [Contents][Index]
In GNU coreutils’ version sort algorithm, the following items have special priority and sort earlier than all other characters (listed in order);
.
’ (a single dot character, ASCII 46)..
’ (two dot characters).
’) sort earlier than strings starting with any other characters.Example:
$ printf "%s\n" a "" b "." c ".." ".d20" ".d3" | sort -V . .. .d3 .d20 a b c
These priorities make perfect sense for ‘ls -v
’: The special
files dot ‘.
’ and dot-dot ‘..
’ will be listed
first, followed by any hidden files (files starting with a dot),
followed by non-hidden files.
For ‘sort -V
’ these priorities might seem arbitrary. However,
because the sorting code is shared between the ls
and sort
program, the ordering rules are the same.