Last active
          March 24, 2019 04:19 
        
      - 
      
- 
        Save oakaigh/7646fdc39bc994f972f98591a2466b64 to your computer and use it in GitHub Desktop. 
    POSIX-compatible DNS lookup function
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | gethostbyname() { | |
| for d in $@; do | |
| address=$(nslookup $d | awk -F: '/Name.*/ { flag = 1; next } | |
| /Address.*/ && flag { print $NF }' | awk '{ print $1 }') | |
| echo ${address:-$d} | |
| done | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment