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
different result on shell and on perl HELP NEEDED nookie Shell Programming and Scripting 2 04-15-2008 01:18 AM
The shell script is not returning proper result clnsharma123 AIX 1 01-25-2008 04:54 AM
Outputting formatted Result log file from old 30000 lines result log<help required> vikas.iet Shell Programming and Scripting 5 12-02-2007 10:43 PM
How to store query multiple result in shell script variable(Array) div_Neev Shell Programming and Scripting 4 11-06-2007 08:10 PM
running 2 shell jobs while waitting for result eyalush Shell Programming and Scripting 2 05-23-2005 09:26 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 01-08-2008
Neerajjaiswal Neerajjaiswal is offline
Registered User
  
 

Join Date: Jan 2008
Location: india
Posts: 3
Could any one tell me how to do get result in fraction in shell script

Could any one tell me how to do get result in fraction in shell script.

I am using expr for division of 2 number but it is giving Quitent.

I need it in full fraction value.

please helpp. how to do it using "dc" or "bc"
  #2 (permalink)  
Old 01-08-2008
ranjithpr ranjithpr is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 157
$echo "10/3"|bc -l
3.33333333333333333333
  #3 (permalink)  
Old 01-09-2008
Neerajjaiswal Neerajjaiswal is offline
Registered User
  
 

Join Date: Jan 2008
Location: india
Posts: 3
Thumbs down If used in awk

How to set the precision in it any gud document on net in this regard... could help me!!! and also if using in awk do this will work, if not then how to make any approach over their??
  #4 (permalink)  
Old 01-09-2008
ranjithpr ranjithpr is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 157
I am not sure what u want. You can user printf to print the result with desired precision.
Eg:
echo "10/3"|bc -l|xargs printf "%.2f"

In awk the syntax for printf is similar to the printf in C,C++
  #5 (permalink)  
Old 01-09-2008
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,557
Quote:
Originally Posted by Neerajjaiswal View Post
How to set the precision in it any gud document on net in this regard... ?

Code:
# echo "scale=4;10/3" | bc
3.3333

look up the man page of bc for a start.
  #6 (permalink)  
Old 01-09-2008
Neerajjaiswal Neerajjaiswal is offline
Registered User
  
 

Join Date: Jan 2008
Location: india
Posts: 3
working on long variable

Hi,

i am working very long variable.

do that way things will work???

ie 1238123781273761273/12368128273871238
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 02:04 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