Skip to content

Instantly share code, notes, and snippets.

@itayadler
Last active August 20, 2018 11:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itayadler/8972307 to your computer and use it in GitHub Desktop.
Save itayadler/8972307 to your computer and use it in GitHub Desktop.
Run nslookup on a list of domains
#!/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