jeudi 27 mai 2021

Check condition with command and integer in bash

I have a code which needs to compare two integers and give the output. Here is the code

if [ `grep -iw "VERSION_ID" /etc/os-release  | cut -d "=" -f2 | tr -d '\"'` > 10 ]
        then
        echo "yes"
else
        echo "no"
fi

Output of the command -> grep -iw "VERSION_ID" /etc/os-release | cut -d "=" -f2 | tr -d '"' is 7.7 So I have to compare this 7.7 with 10 and print output. But it is not working for me. Any other suggestions are appreciated

Aucun commentaire:

Enregistrer un commentaire