[HPADM] SUMMARY How to find percent in a script

From: Brendan Doherty (bdoherty@itl.ca)
Date: 04/24/03

  • Next message: Dave T.: "[HPADM] SUMMARY: Installing RAM on an N4000 w/ 11.0"
    Date: Thu, 24 Apr 2003 11:45:34 -0400
    From: "Brendan Doherty" <bdoherty@itl.ca>
    To: "hpux-admin@dutchworks.nl" <hpux-admin@dutchworks.nl>
    
    

    Hi thanks for all the responses.. it was an easy problem - just I could not see it.

    here is one way to get % .
    Brendan

    The expr command works on integers and when dividing gives you modulus.
    Because 20 divided by 80 is 0 remainder 20 that is why you are getting 0.
    Try this:
    VALUEONE=20
    VALUETWO=80
    PERCENT=`expr \( $VALUEONE \* 100 \) / $VALUETWO`
    echo $PERCENT
    You might like to change the echo statement to:
    echo ${PERCENT}%
    so you get a nice percent sign as well.

    Brendan Doherty wrote:

    > Hi I keep on getting 0 ... seems like it does not like to divide ...
    > anyone know how to calculate a percent from to #'s
    >
    > VALUEONE=20
    > VALUETWO=80
    >
    > PERCENT=`expr $VALUEONE / $VALUETWO \* 100 `
    >
    > echo $PERCENT
    >
    > ----
    > I receive 0 ,,, it should be .25..
    > 20/80 * 100 =0.25 ; seems like to 20/80 is returning 0.
    >
    > thanks
    >
    > --
    > ---> Please post QUESTIONS and SUMMARIES only!! <---
    > To subscribe/unsubscribe to this list, contact majordomo@dutchworks.nl
    > Name: hpux-admin@dutchworks.nl Owner: owner-hpux-admin@dutchworks.nl
    >
    > Archives: ftp.dutchworks.nl:/pub/digests/hpux-admin (FTP, browse only)
    > http://www.dutchworks.nl/htbin/hpsysadmin (Web, browse & search)

    --
                 ---> Please post QUESTIONS and SUMMARIES only!! <---
            To subscribe/unsubscribe to this list, contact majordomo@dutchworks.nl
           Name: hpux-admin@dutchworks.nl     Owner: owner-hpux-admin@dutchworks.nl
     
     Archives:  ftp.dutchworks.nl:/pub/digests/hpux-admin       (FTP, browse only)
                http://www.dutchworks.nl/htbin/hpsysadmin   (Web, browse & search)
    

  • Next message: Dave T.: "[HPADM] SUMMARY: Installing RAM on an N4000 w/ 11.0"

    Relevant Pages

    • Re: Issue with Selected Text Colour
      ... When I read the other responses I did feel bit of a fool! ... By the way I have just read the thread about Australian Thanksgiving and thought it was so funny. ... Certainly lightens thinks up if you are feeling a little bit over awed with PowerPoint.I read all the postings even though I don't know what half of them mean, perhaps a little bit of the information I read about may just come to the front when needed. ... Echo thanks again for response. ...
      (microsoft.public.powerpoint)
    • Re: sorting 3 input numbers
      ... On Tue, 21 Oct 2003 at 10:10 GMT, Stefan Dask wrote: ... > thank you for your responses. ... echo "Enter three numbers:" ... My code in this post is copyright 2003, Chris F.A. Johnson ...
      (comp.unix.shell)
    • entering bios with Labview serial vis
      ... am able to enter the bios with hyperterminal and see all the responses ... information to the bios in labview with either the serial vis or visa I ... that hyperterminal does automatically to get this info to echo out the ... when automating with expect.  However, in labview, this does not ...
      (comp.lang.labview)
    • Re: 6 months!
      ... Not to worry about any responses other than this one from me, ... giant "thank you". ... > Echo wrote: ... > I have had responses to the picture I posted for your HOF... ...
      (alt.support.stop-smoking)
    • Re: Capturing the output of transparent commands (e.g., @@CONS T,D D).
      ... After @@ECHO ON was entered, ... The Theorem Theorem: If If, ...
      (comp.sys.unisys)