News for hackers. Stuff that matters.
Re:The lack of a good command line way to sort IPv6 addresses by andix on Wednesday May 21, 2025 @12:11PM (#44053013)
I'm creating all those tiny shell helper scripts now with AI. One of the things AI is really good at.

prompt: create a bash command to sort a text file of ipv6 adresses per line. sort numerically (128 bit representation) but keep the full line as originally formatted

result:

  while read -r ip; do
    printf '%032x %s\n' \
      "$(python3 -c 'import ipaddress,sys; print(int(ipaddress.IPv6Address(sys.argv[1])))' "$ip")" \
      "$ip" 
  done < ipv6.txt | sort | cut -d' ' -f2-
Re:The lack of a good command line way to sort IPv6 addresses by kstrauser on Wednesday May 21, 2025 @01:55PM (#44054208)
That’s launching Python once per address. Why not just pipe it into a short Python script at that point?
Re:The lack of a good command line way to sort IPv6 addresses by andix on Wednesday May 21, 2025 @02:13PM (#44054406)
I know, this could be a follow-up prompt. But I tested it and it works well.

It's just to demonstrate how easy it is to solve those problems without spending an unnecessary amount of time on them.

Re:The lack of a good command line way to sort IPv6 addresses by kstrauser on Wednesday May 21, 2025 @03:27PM (#44055259)
Legit.