Created
September 19, 2018 10:20
-
-
Save iMartyn/25c75e19e9466cfd6f322b24e036f34b to your computer and use it in GitHub Desktop.
awk and grep to convert dns zonefile to hosts file
This file contains 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
#!/bin/bash | |
ZONEFILE=$1 | |
grep 'ORIGIN\|A\W\+[0-9]\{1,3\}' $ZONEFILE | awk '{if ($1 == "$ORIGIN") {mydomain=$2} else if ($2 == "A") {print $3 " " mydomain} else {{print $4 " " $1 "." mydomain}}}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment