LoginSignup
1
1

More than 5 years have passed since last update.

hostsファイルに列挙されたアドレスへのpingチェック

Posted at

$ grep -v # /etc/hosts | grep -v 127 | awk '{print $1}' | ./pinger.sh

$ cat pinger.sh

!/bin/sh

trap 'exit 1' 2
while read host
do
ping -o -t 1 $host > /dev/null
if [ $? == 0 ]
then
echo "$host OK"
else
echo "$host NG"
fi
done

1
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1