Last active
August 20, 2018 11:00
-
-
Save itayadler/8972307 to your computer and use it in GitHub Desktop.
Run nslookup on a list of domains
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
usage() { | |
echo "Runs nslookup on a list of domains given by a text file, each domain separated by a newline." | |
echo "Usage: path_to_textfile.txt" | |
exit 1 | |
} | |
# call usage() function if no file name is supplied | |
[[ $# -eq 0 ]] && usage | |
while read line | |
do | |
domain_name=$line | |
domain_resolve=`nslookup $domain_name | grep -m 1 Name: | awk '{print $2}'` | |
echo -e "$domain_name\t$domain_resolve" | |
done < $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment