$ ls |sort
xyz-0.0.1-1554490900.rpm
xyz-0.0.1-1554745305.rpm
xyz-0.0.1-1554751021.rpm
xyz-0.0.1-1555513460.rpm
xyz-0.0.1-1555951745.rpm
xyz-0.0.1-1554323568.rpm
$ /bin/ls |sort
xyz-0.0.1-1554323568.rpm
xyz-0.0.1-1554490900.rpm
xyz-0.0.1-1554745305.rpm
xyz-0.0.1-1554751021.rpm
xyz-0.0.1-1555513460.rpm
xyz-0.0.1-1555951745.rpm
$ which ls
alias ls='/bin/ls --color'
/bin/ls
Note that the sorting is different between the two commands (ls |sort
results in incorrect sorting). This must be due to the color flag, but why?
ls
, in many cases, you may found useful to specify directly the-v
option:ls -v
. Better to avoid the deprecated and risky parsing of its output... In many modern distributions the alias ofls
is directly set to/bin/ls --color=auto
, as they suggest you in an answer.\033[91m
. Once you imagine the colour codes that are output byls
(normally consumed by the terminal), you can see why your sort would break (and then, the terminal strips them out so you can't see why the sort broke). I'm guessing the results were grouped by colour, then sorted by name?