GNU bug report logs -
#72617
sort -n loses lines.
Previous Next
Reported by: Simon B <simon.buongiorno <at> gmail.com>
Date: Wed, 14 Aug 2024 09:14:01 UTC
Severity: normal
Tags: notabug
Done: Pádraig Brady <P <at> draigBrady.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
tag 72617 notabug
close 72617
stop
On 14/08/2024 09:43, Simon B wrote:
> Hallo,
>
> The output of my grep command is:
>
> # grep -i "sshd" /root/access.report | egrep -o
> '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-
> 9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)'
> 64.227.127.122
> 172.169.5.249
> 172.169.6.164
Adding the --debug option shows the issue.
I.e. the '.' being considered as part of a number:
$ sort --debug -rbn -s ips
sort: text ordering performed using ‘en_IE.UTF-8’ sorting rules
sort: note numbers use ‘.’ as a decimal point in this locale
178.128.44.128
_______
172.169.6.164
_______
172.169.5.249
_______
Taking the example for sorting IPv4 addresses from the manual,
shows the desired comparisons being performed:
$ sort --debug -t '.' -k 1,1rn -k 2,2rn -k 3,3rn -k 4,4rn -u ips
sort: text ordering performed using ‘en_IE.UTF-8’ sorting rules
sort: numbers use ‘.’ as a decimal point in this locale
178.128.44.128
___
___
__
___
172.169.6.164
___
___
_
___
172.169.5.249
___
___
_
___
cheers,
Pádraig
This bug report was last modified 279 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.