3 ms·
With jq and curl curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | jq '.prefixes | .[].ip_prefix | .[-3:]' | sort | uniq -c
by tempest_ 6y ago
With jq and curl
curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | jq '.prefixes | .[].ip_prefix | .[-3:]' | sort | uniq -c
- xorcist 6y ago".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!