I want to write a script, that would keep checking if any of the devices in network, that should be online all day long, are really online. I tried to use ping, but
You don't need the backticks in the if statement. You can use this check
if ping -c 1 some_ip_here &> /dev/null
then
echo 1
else
echo 0
fi
The if command checks the exit code of the following command (the ping). If the exit code is zero (which means that the command exited successfully) the then block will be executed. If it return a non-zero exit code, then the else block will be executed.