HELP!! Having trouble with bash script - need quick response

Posted on 2006-04-12
Last Modified: 2010-04-22
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:


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??

Question by:Tigger996
    LVL 84

    Expert Comment

    if perl -e 'exit ( (shift) < (shift)); '  $temphigh $templow ; then  echo low ; fi

    Author Comment

    I'm pretty new to this - I don't quite understand that script

    LVL 84

    Accepted Solution

    if awk "BEGIN{ exit $temphigh < $templow }" ; then echo high ; fi

    Author Comment

    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.

    LVL 84

    Expert Comment

    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.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
    The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now