I am using this script on Ubuntu & it works fine
status="$(curl -Is http://www.google.com | head -1)"
validate=( $status )
if [ ${validate[-2]} == "200" ]; then
echo "OK"
else
echo "NOT RESPONDING"
fi
but when I run it on my Raspberry Pi it generates this error:
validate: bad array index
[: ==: unary operator expected
I guess it's from the bash version I tried:
if [ "$ {validate [-2]"} == "200" ]; then
But it does not work.
myUbuntu bash version : 5.0.17
myRaspebbry PI bash version : 5.0.3