Skip to content

Instantly share code, notes, and snippets.

@siriniok
Last active April 18, 2018 17:16
Show Gist options
  • Save siriniok/0ae5427b22dc67889a157dd077f3d8a9 to your computer and use it in GitHub Desktop.
Save siriniok/0ae5427b22dc67889a157dd077f3d8a9 to your computer and use it in GitHub Desktop.
Get rid of sed and awk with jq and ruby
# Shows the number of AWS IPs
curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | jq '.prefixes[].ip_prefix' | xargs ruby -e "puts ARGV.reduce(0) { |acc, i| acc + 2**(32 - i.split('/')[1].to_i) }"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment