I've got a web server with a bunch of domains that have different name servers and I'm trying to clean up the mess. I'm trying to get a list of the domains and their name servers. I've got this simple script written and it almost works:
#!/bin/bash
for f in `cat mydomains.txt`
do
echo $f " " >> mydns.txt
dig ns $f | grep '^$f' | cut -d $'\t' -f 5 >> mydns.txt
echo "" >> mydns.txt
done
As of right now, all this does is echo $f " " >> mydns.txt
.
If I take the dig line and substitute what $f
should be in the command line, I get the expected results. However, I get nothing in my script. I know that the $f
variable is populated because it echoes $f
in the previous line. Why doesn't it work in the script ?