On Wednesday, May 27, 2020 2:07:32 PM CEST Danie de Jager via GNU coreutils Bug Reports wrote: > Hi, > > I use sort -Vr to sort version numbers. I noticed this discrepancy on > the latest kernel version from Centos 7.8. > > command to get output: > # ls -t /boot/vmlinuz-* | sed "s/\/boot\/vmlinuz-//g" | grep -v rescue > > | sort -Vr > > 3.10.0-1127.el7.x86_64 > 3.10.0-1127.8.2.el7.x86_64 > 3.10.0-1062.18.1.el7.x86_64
It is the underscore in the .x86_64 suffix what breaks the version compare algorithm. If you replace the underscore by an alphabetic character, it sorts as you expect: # ls -t /boot/vmlinuz-* | sed "s/\/boot\/vmlinuz-//g" | grep -v rescue | \ sed 's/x86_64/x86X64/' | sort -Vr | sed 's/x86X64/x86_64/' 3.10.0-1127.8.2.el7.x86_64 3.10.0-1127.el7.x86_64 3.10.0-1062.18.1.el7.x86_64 Kamil > I'd expect the middle value to be the highest version number. Is this > by design or a bug? If it is a bug please let me know if I must log it > somewhere. > > Version details: > # sort --version > sort (GNU coreutils) 8.22 > Copyright (C) 2013 Free Software Foundation, Inc. > License GPLv3+: GNU GPL version 3 or later > <http://gnu.org/licenses/gpl.html>. This is free software: you are free to > change and redistribute it. There is NO WARRANTY, to the extent permitted > by law. > > Written by Mike Haertel and Paul Eggert. > > Regards, > Danie de Jager