samedi 27 juillet 2019

Bash ping command in if statement with square brackets does not work [duplicate]

This question already has an answer here:

This works:

if ! ping -q -c 1 -W 1 google.com > /dev/null; then
   echo "google not reachable"
fi

but this does not work:

if [ ! `ping -q -c 1 -W 1 google.com > /dev/null` ]; then
    echo "google not reachable"
fi

Why does the second statement not work? Is it not basically the same?

Aucun commentaire:

Enregistrer un commentaire