3 ms·
".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-ran
by 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!