I'm trying to use a shell variable in the following awk command.
Code:
awk '/"domain.com"/,/^};/' named.conf
That will run properly, and output the zone data for domain.com.
What I want to do is replace "domain.com" with a shell variable that will have changing values.
I am having a problem with shell variables in this usage of awk. As a test I did this,
Code:
$ DOMAIN=example.com
$ awk -v zone=$DOMAIN 'BEGIN { print zone}'
example.com
Works fine, however when I try to use it with the initial awk command it doesn't work as expected.
Code:
awk -v domain=$ZONE '/domain/,/^};/' named.conf
Where $ZONE is equal to a valid zone in named.conf returns nothing. It is instead looking for the word "domain" and not the variable.
Thanks in advance