The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How can I get a processor's CPU Percentage? sangjinn High Level Programming 3 10-09-2008 08:28 AM
how to get the percentage of completion? during a copy! wrapster UNIX for Advanced & Expert Users 7 05-24-2008 01:55 AM
how do I calculate percentage ? the_learner High Level Programming 6 04-18-2007 04:40 PM
how to make percentage of a running script? jimmbp Shell Programming and Scripting 1 01-31-2006 02:41 PM
percentage sign in a drive mapping ? simon2000 UNIX for Advanced & Expert Users 2 09-17-2002 12:30 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-09-2004
preetikate preetikate is offline
Registered User
  
 

Join Date: Feb 2004
Posts: 13
Computung Percentage

I wish to find % used using shell variables
and am using the following

USED=`expr $1\* 100 / $2`;

But this does not take decimal portion of $1 .
How to resolve?

  #2 (permalink)  
Old 02-09-2004
cbkihong cbkihong is offline Forum Advisor  
Advisor
  
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,624
I believe sh doesn't support floating point arithmetic. You may need to resort to external languages, say Perl or Tcl for this purpose.
  #3 (permalink)  
Old 02-09-2004
oombera's Avatar
oombera oombera is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2002
Location: Cleveland, OH
Posts: 804
Actually, the OP didn't say whether they were using sh or not.

If you have the "bc" command installed, you can do something like: USED=`echo "$1 * 100 / $2" | bc`

Read these posts:
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:46 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0