What I would do :
for i in "${array[@]}"; do
ping -c1 "$i" &>/dev/null && echo "$i ON" || echo "$i OFF"
done
What I would do :
for i in "${array[@]}"; do
ping -c1 "$i" &>/dev/null && echo "$i ON" || echo "$i OFF"
done