Re:The lack of a good command line way to sort IPv6 addresses
by Symbiote on Wednesday May 21, 2025 @11:02AM
(#44052240)
It could be reasonable to extend sort to support a hexadecimal numeric sort. It already supports numeric (decimal) and human-readable with SI prefixes (2k, 1G).
Re:The lack of a good command line way to sort IPv6 addresses
by thesuitonym on Thursday May 22, 2025 @09:32AM
(#44061891)
Hexadecimal sort is already the same as alphabetic sort. The main problem with IPv6 addresses is that zeroes get truncated all over the place. :: could mean :0000: or :0000:0000:0000:. It's not impossible to solve by any means, but pure hexadecimal sort wouldn't work.
Re:The lack of a good command line way to sort IPv6 addresses
by pantalaimon on Wednesday May 21, 2025 @09:43AM
(#44051374)
How often do you need to sort IP addresses to begin with?
Re:The lack of a good command line way to sort IPv6 addresses
by j16sdiz on Wednesday May 21, 2025 @09:50AM
(#44051445)
When you have lots of addresses and subnets, and want to see which addresses goes into what subnet
Re:The lack of a good command line way to sort IPv6 addresses
by fragmede on Wednesday May 21, 2025 @10:25AM
(#44051775)
especially since ipv6 can be multi-homed. on corporate networks you ended up with difficult configurations and need to figure out why the packets are going the wrong way frequently.
Re:The lack of a good command line way to sort IPv6 addresses
by fragmede on Wednesday May 21, 2025 @12:27PM
(#44053171)
> Probably better in this case would be to have a small program that expands IPv6 addresses that you could then pipe into sort. That would be more in-keeping with the Unix Way™.
I went and wrote this and then realized you'd need two utilities. One to expand the addresses, and one to minify the addresses, so your pipeline would be:
cat ipv6-addrs.txt | ipv6expand | sort -V | ipv6minify
vs cat ipv6-addrs.txt | sort -6
The unix philosphy is do one thing and do it well. Ideally sort does sorting very well, including sorting of ipv6 addresses. Ergo, sort should handle ipv6 address sorting.
Probably better in this case would be to have a small program that expands IPv6 addresses that you could then pipe into sort. That would be more in-keeping with the Unix Way™.