Created
July 7, 2020 19:36
-
-
Save PatrickCronin/07dc0600f45721ec8352a898c8349326 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach inputs as $in ( | |
{}; | |
if has("postcode") and has("network") then null | |
else . as $x | |
| $in | |
| if length == 1 and .[0][-1] == "Record" then {} | |
elif length == 2 and .[0][-1] == "Network" then ($x + {network: .[-1]}) | |
elif length == 2 and .[0][-2] == "postal" and .[0][-1] == "code" and .[-1] == "12061" then ($x + {postcode: .[-1]}) | |
else $x | |
end | |
end; | |
select( has("postcode") and has("network") ) | .network | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run as:
mmdbinspect -db /usr/local/share/maxmind/GeoIP/GeoIP2-City.mmdb 0.0.0.0/0 | jq --stream -nr -f networks-for-postcode.jq
.Note that
mmdbinspect
is not fully capable of being used like this as it doesn't stream its output. Memory runs out.