Linux commands

Now we want to write a bash script to ping to our hosts instead
of ping each host one by one

1) we need one file which we save the ip hosts
2) we need a file to write our bash script

first file is a text file create by this command:
vi hosts
an then write your IPs

second file create by command:

Vi Ping

then write the bash script:
#!/bin/bash
Hosts=” the path of the first file “
for ip in $($cat $hosts)
do
ping -c1 $ip &>/dev/null #by this command the ping does not appear on the screen
if [ $ip -eq 0 ]
then
echo $ip is ok
else
echo $ip is not ok
fi
done

--

--