Search code examples
bashdig

dig linux script shows results from txt file


I would like to have a script that will dig domain_name ANY from multiple domains stored on a domains.txt file and output the results to a results.txt file...but easy to read if possible

Is this thing possible?


Solution

  • Given you have a list in a file named domains_list.txt you can use this command:

    for d in $(cat domains_list.txt); do echo Processing domain: $d;  dig $d | grep -v "^;" | tee ${d}_result.txt; done
    

    To have a better answer you should give a better question ;)

    Edit: to have it in just one file, with dig ANY :

    for d in $(cat domains_list.txt); do echo Processing domain: $d;  dig $d ANY| grep -v "^;" | tee -a results.txt; done