3 ms·
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
by andix 1y ago
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-
- kstrauser 1y agoThat’s launching Python once per address. Why not just pipe it into a short Python script at that point?