Skip to content

Instantly share code, notes, and snippets.

@centur
Forked from mrlesmithjr/dig2JSON
Created February 22, 2022 22:39
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 centur/fb342c10c11d4c5a266766d74f6d1401 to your computer and use it in GitHub Desktop.
Save centur/fb342c10c11d4c5a266766d74f6d1401 to your computer and use it in GitHub Desktop.
dig results to parsable json
foo=$(dig google.com +nocomments +noquestion +noauthority +noadditional +nostats | awk '{if (NR>3){print}}'| jq -R 'split("\t") |{Name:.[0],TTL:.[2],Class:.[3],Type:.[4],IpAddress:.[5]}' | jq --slurp .) | jq -n --argjson v $foo '{"foo": $v}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment