title: test if hostname exists from command line without ping
body: <p>we have a script that needs to take action on a finite list of hosts.  but every time we add or remove a host to the /etc/hosts file, we end up having to update this script.</p>
  
  <p>basically, say my hosts file looks like:</p>
  
  <pre><code>192.168.100.1     hostip_1
  192.168.100.2     hostip_2
  192.168.100.10    hostip_3
  192.168.100.20    hostip_5
  </code></pre>
  
  <p>and my script (bash) does something like:</p>
  
  <pre><code>callmyfunction hostip_1
  callmyfunction hostip_2
  callmyfunction hostip_3
  callmyfunction hostip_5
  </code></pre>
  
  <p>if i want to add hostip_4 to the list of hosts, i now have to go in and edit my script and add it to the list.  while it's a small edit, it is still a step that can be forgotten in the process (especially if someone new to the system comes in).</p>
  
  <p>is there a way i can test to see if 'hostip_1' is a valid hostname within the system (without pinging the host or grepping the /etc/hosts file)?  we may use multiple hosts files, and different configurations may have different filenames, so i can't rely on trying to grep a single file.  i need the system to do that work for me.</p>
  
  <p>any clues?</p>