lundi 27 juin 2016

Shell scripting - Comparing floating number within if then else [duplicate]

This question already has an answer here:

I need to make a comparison between floating numbers within the if. For example,

if [1.1 -gt .45] && [1.1 -lt 2.9]

Then ...

fi

In the case of my program I've tried ...

if [ "$ {restogpsweek [0]} -gt 0.1"] && [ "$ {restogpsweek [0]} -lt 2.2"]

if [ "$ {restogpsweek [0]} -gt 0.1" | bc] && [ "$ {restogpsweek [0]} -lt 2.2" | bc]

if [echo" $ {restogpsweek [0]} -gt 0.1 "| bc] && [ echo" $ {restogpsweek [0]} -lt 2.2 "| bc]

and "n" other things and not found ...

Does anyone know how to do these comparisons?

Hugs

Aucun commentaire:

Enregistrer un commentaire