Skip to content

Instantly share code, notes, and snippets.

@ricardomaia
Last active March 1, 2023 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ricardomaia/76fedd58d98d4a3a527508d307f5c1ea to your computer and use it in GitHub Desktop.
Save ricardomaia/76fedd58d98d4a3a527508d307f5c1ea to your computer and use it in GitHub Desktop.
Download and transform the list of Google IP ranges from JSON to CSV

Download and transform the list of Google IP ranges from JSON to CSV using curl, jq and sed.

curl https://www.gstatic.com/ipranges/goog.json | \
jq -r '.prefixes[].ipv4Prefix, .prefixes[].ipv6Prefix |  select (. != null)' | sed 's/^\|$/"/g' | paste -sd, - \
&& curl https://www.gstatic.com/ipranges/cloud.json | \
jq -r '.prefixes[].ipv4Prefix, .prefixes[].ipv6Prefix | select (. != null)' | sed 's/^\|$/"/g'| paste -sd, - \
> google-ranges.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment