News for hackers. Stuff that matters.
Re:Amazon owns more than $2B worth of IPv4 addresses by xorcist on Saturday December 12, 2020 @03:05PM (#25401166)
".a | .b" is just ".a.b" in jq.

Netmasks might not always be three characters.

Perhaps something like this:

  curl -sf https://ip-ranges.amazonaws.com/ip-ranges.json | jq -r '.prefixes[].ip_prefix' | grep -o '/.*' | sort | uniq -c
If you really wanted to, you could even do the splitting and counting in jq:

  curl -sf https://ip-ranges.amazonaws.com/ip-ranges.json | jq 'reduce (.prefixes[].ip_prefix | split("/")[1]) as $mask ({}; .[$mask] += 1)'
It's a super handy tool with a real language in there!

There are no comments on this comment yet.