What am I doing wrong?
This works:
ns="ns.nameserver.co.uk"
d="domain.co.uk"
dig @$ns $d A | grep $d
However using just a variable after pipe does not (it hangs):
ns="ns.nameserver.co.uk"
d="domain.co.uk"
g=$(grep $d | grep -v "DiG")
dig @$ns $d A | $g
Do I need to do something special after the pipe so it knows to run the grep command from the g variable? Using backticks (historic) fails as well.
Use eval
ns="ns.nameserver.co.uk"
d="domain.co.uk"
g="grep $d | grep -v 'DiG'"
dig @$ns $d A | eval $g