News for hackers. Stuff that matters.
Re:The lack of a good command line way to sort IPv6 addresses by fragmede on Monday May 19, 2025 @01:52AM (#44026805)
It's ipv6. Seems like the "standard" thing to do would be to write and name a utility called sort6 which properly handles ipv6 addresses.
Re:The lack of a good command line way to sort IPv6 addresses by Gabrys1 on Monday May 19, 2025 @02:22AM (#44026952)
I imagine you wrote this sarcastically, but I do like this a lot!
Re:The lack of a good command line way to sort IPv6 addresses by fragmede on Monday May 19, 2025 @10:03AM (#44030047)
The original sort (and ping, and traceroute) could just have been updated to handle the newer format, rather than creating new utilities, was my non-sarcastic point. :)
Re:The lack of a good command line way to sort IPv6 addresses by thesuitonym on Wednesday May 21, 2025 @09:19AM (#44051153)
True of ping and traceroute, but sort is not a network utility, so editing it to specifically handle IPv6 addresses is kind of a weird idea. Not necessarily a bad idea, but it makes sense that nobody has done it.

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™.

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.
Re:The lack of a good command line way to sort IPv6 addresses by blueflow on Wednesday May 21, 2025 @10:55AM (#44052142)
Usually ping6 and traceroute6 are symlinks to the regular util, not a different program.
Re:The lack of a good command line way to sort IPv6 addresses by hinkley on Wednesday May 21, 2025 @11:30AM (#44052558)
`sort -n` works remarkably well on `du`’s output
Re:The lack of a good command line way to sort IPv6 addresses by fragmede on Wednesday May 21, 2025 @11:39AM (#44052660)
if you're using gnu sort, there's sort -h for du -ch's output
Re:The lack of a good command line way to sort IPv6 addresses by hinkley on Wednesday May 21, 2025 @02:36PM (#44054667)
Works great if the first column represents sizes. Not so great with IP addresses I suspect.
Re:The lack of a good command line way to sort IPv6 addresses by Ekaros on Wednesday May 21, 2025 @09:32AM (#44051271)
Isn't that Unix philosophy? Make tool that does one thing well. That is sort IPv6 addresses.