help with using text file as input

Hello All,

I'm attempting to use a text file as input to a specific field in a command. Below is the command...

Typically it looks like this

ans_dump testzone.com channel=dnsw32 | grep AAAA

I have about 500 zones I want to check... how do I use my text file as input where the zone name would be? Thanks.

ans_dump <text file input here> channel=dnsw32
while read LINE
do
        ans_dump "${LINE}" channel=dnsw32
done < inputfile

---------- Post updated at 12:36 PM ---------- Previous update was at 12:35 PM ----------

Depending on how ans_dump works it may be possible to run it fewer times, cramming more input into it, which would be more efficient, but I don't know anything about ans_dump. Can you put channel=... before the rest instead of after? Will it accept more than one name after it and do what you want?

---------- Post updated at 12:41 PM ---------- Previous update was at 12:36 PM ----------

Also, if you want to run grep on the output, you can do it collectively:

while read LINE
do
        ans_dump "${LINE}" channel=dnsw32
done < inputfile | grep whatever
1 Like

That worked perfectly. Grep doesn't seem to be filtering what I want but it is using the file as the source for the zones.

Below is the code i'm using.

Thank you!

while read LINE; do ans_dump "${LINE}" channel=dnsent01; done < dnsentzones.txt | grep AAAA

EDIT: Actually I was mistaken, the grep is working properly. Thanks again.

1 Like