Hello,

I need to seperate multiple domains by having and not having A records.

I have created a shell script like below, but it is not working, as the $? is same (0) for both the dig commands that have and not have A records.

*************************

!/bin/bash

for dom in cat /home/xxxx/domainslist.txt
do

result= dig +noall +answer $dom

if [ "$result" != '') ];then

echo $dom >> /home/xxxx/havingA.txt

else

echo $dom >> /home/xxxx/havingNoA.txt

fi

done

**************************

Please help me if there is any other way we can do this. Thank you.

There is a small syntax error in my previous code and it is corrected as

if [ "$result" != '' ];then

The issue persists. Please help me if anyone have a better idea of doing this.

:-) I have figured it out.

#!/bin/bash

for dom in cat /home/xxxx/domainslist.txt

do

result=$(dig +noall +answer $domains | awk '{print $5}')

if [ "$result" != '' ];then

echo "$dom" >> /home/xxxx/havingA.txt

else

echo "$dom" >> /home/xxxx/havingNoA.txt

fi

done

This will dig the domains one by one that is listed in the domainslist.txt and will seperate by having Address record and not.

Thanks for everyone who tried. :-)