Tigger996
asked on
HELP!! Having trouble with bash script - need quick response
Here's where I'm stuck
temphigh=$(cat $d/temphigh | sed 's/ //g');
templow=$(cat $d/templow | sed 's/ //g');
actualtemp=$(cat $d/temperature | sed 's/ //g');
I have the sed part in there because the file has leading spaces:
temphigh=80.124
templow=20.212
actualtemp=55.129
What I can't get is I need to compare the actualtemp to temphigh and templow
But how do I compare these values - when -lt and -gt needs integer??
temphigh=$(cat $d/temphigh | sed 's/ //g');
templow=$(cat $d/templow | sed 's/ //g');
actualtemp=$(cat $d/temperature | sed 's/ //g');
I have the sed part in there because the file has leading spaces:
temphigh=80.124
templow=20.212
actualtemp=55.129
What I can't get is I need to compare the actualtemp to temphigh and templow
But how do I compare these values - when -lt and -gt needs integer??
if perl -e 'exit ( (shift) < (shift)); ' $temphigh $templow ; then echo low ; fi
ASKER
I'm pretty new to this - I don't quite understand that script
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your code: I used the awk one but how come the logic is backwards. Because logically if actualtemp is < templow shouldn't it echo low not high? It works if I do it backwards. But just wondering why it is like this.
Because of the convention that a 0 exit value is used for a success, and a non-zero exit value is used to indicate a failure.