The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Date Calculations mitschcg UNIX for Dummies Questions & Answers 8 03-06-2009 04:40 AM
how do you get input of a file to calculations nadman123 Shell Programming and Scripting 6 04-11-2008 04:14 AM
Time Calculations Nysif Steve UNIX for Dummies Questions & Answers 5 09-14-2007 09:49 AM
Float calculations sharmavr UNIX for Dummies Questions & Answers 1 07-26-2006 03:18 AM
Line Count Calculations redlotus72 UNIX for Dummies Questions & Answers 4 05-09-2005 09:23 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-14-2008
cesarNZ cesarNZ is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 70
ksh, calculations using bc

hi all,
was wondering if there is another way to do calculations in ksh scripts other than using bc ?? i am using a script to calculate average response time and my script errors out after running for a bit.

e.g code i am using :

averageTime=$(print "$totalTime / $numberOfEntries" | bc);

since the numbers are quite large i am guessing the script errors out due to that.


any suggestions on what else to use ??


thanks.
  #2 (permalink)  
Old 12-14-2008
frank_rizzo frank_rizzo is offline Forum Advisor  
Resident BOFH
  
 

Join Date: Dec 2007
Posts: 426
you can use ksh but it only supports integers. What do you mean by "errors out"? Do you have an error message?


Code:
averageTime=$(( totalTime / numberOfEntries ))

  #3 (permalink)  
Old 12-14-2008
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,409
Try...
Code:
averageTime=$(echo "$totalTime $numberOfEntries" | awk '{print $1 / $2}' );

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 06:20 PM.


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