coolcommands.com - the search engine for unix sysadmins :: unix commands and scripts
Thursday May 23, 2013


 Home
 Search
 Advanced Search
 Category Search
 Affiliates
 Acknowledgements
 Cool Links

Username

Password

Remember me
Forgot your password?

Who's Online
We have 19 guests online

Newest Member

nbewwmbxog

Hit Counter
11566147 Visitors

cool Statistics
coolcommands:1338
Categories:83
Total queries:620330
Members:22813





Category Search coolcommands.com
Select Category:


coolcommand

bc - how to do calculations in a script
Description

To do basic arithmetic in a script, you can use the expr command or the bc command.

Here is how you can set a variable in a script:

x=$(printf "%s\n" 'scale = 10; 104348/33215' | bc)

If your values to calculate are in variables, here is how to do it:

In=`echo "scale = 2\\n((8*$InOctets)/($Speed*100))*$5" | bc`

Note: the scale sets the precision of the answer (number of digits after the decimal point)
Example

x=$(printf "%s\n" 'scale = 10; 104348/33215' | bc)

Return to search results

Random coolcommands

coolcommand: errdead - how to extract error records from a system dump in IBM AIX
Example: /usr/lib/errdead /dev/hd7
[show me the details]
coolcommand: DB2 - incorrectly terminated error message at startup
Example: ln -s .. .ftok
[show me the details]
coolcommand: how to list the contents of a yet to be installed RPM package in Linux
Example: rpm -qpl ethereal-0.8.18-1.aix4.3.ppc.rpm
[show me the details]
coolcommand: how to execute a task in SUMA in AIX 5L
Example: suma -x -w -a Action=Download 23
[show me the details]

coolcommands.com - the search engine for UNIX sysadmins :: unix commands and scripts



FREE
myPMS

Password
Management
System

by

LVOware.com




Top 5 Submitters

lvo1160
audet37
kah00na32
Mariom24
lebjf00014

Top 5 Searches

Category Solaris51966
Category AIX49058
Category General UNIX47581
solaris23554
aix22739

Terms of Use
Privacy
Contact


 
coolcommands.com © 2013. All Right Reserved.
Programming by PRATTICO Consulting . Hosting by Apricusum