Text Link Ads

Friday, April 20, 2007

Ping the host table

Here is a quick way to ping all the hosts in your host table. NOTE: Just make sure that there are no blank lines in it, and verify the ping command on your system exist after one ping. Your
mileage may differ slightly.

$ grep -v "#" /etc/hosts | awk '{print $1}' | while read host
> do
> ping -c 1 $host
> done

Or script it:

#!/bin/sh
grep -v "#" /etc/hosts | awk '{print $1}' | while read host
do
ping -c 1 $host
done

No comments: