title: Efficient way to get ip addresses based on a list of hostnames
body: <p>I had to gather a list of IP addresses from a list of hostnames, this is what I came up with:</p>
  
  <pre><code>#!/bin/bash                                                                                                
  Hosts='host1 host2 host3 host4 host5 host6 host7' 
  
  for h in $Hosts                                                                                            
  do                                                                                                         
      echo "$h : " $(ping -c 1 $h | egrep -o -m 1 '\([0-9]+\.[^\(\r\n]*\)')    done 
  </code></pre>
  
  <p>Is there a more efficient way to do this?</p>