Advertisement
Guest User

Hostname resolving

a guest
Nov 20th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.58 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Comment this if statement if you don't want to clean address file each time
  4. if [ -s addresses.txt ]
  5.     then
  6.         rm -f addresses.txt
  7.         touch addresses.txt
  8. fi
  9.  
  10. while read line
  11. do
  12.     result=$(dig "$line" +short)
  13.     if [ -n "$result" ];
  14.         then
  15.             echo "$result" >> addresses.txt
  16.             echo "$result"
  17.         else
  18.             echo "$line" >> addresses.txt
  19.             echo "$line"
  20.     fi
  21. done < hostnames.txt
  22.  
  23. # Comment these lines if you don't want to clean hostname file each time
  24. rm -f hostnames.txt
  25. touch hostnames.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement