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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
bash. convert mpeg adts to normal mp3 stahoo23 Shell Programming and Scripting 5 05-18-2008 02:26 AM
Distribution Release: Scientific Linux 5.1 iBot UNIX and Linux RSS News 0 01-16-2008 04:10 PM
How to add/multiply numbers with scientific notation (2.343e-5) chugger06 UNIX for Dummies Questions & Answers 1 01-26-2006 06:03 PM
how to convert from korn shell to normal shell with this code? forevercalz Shell Programming and Scripting 21 11-22-2005 10:18 PM
Easy UNIX notation question lavaghman UNIX for Dummies Questions & Answers 1 06-05-2002 12:20 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-04-2006
Registered User
 

Join Date: Oct 2005
Posts: 31
Question How to Convert scientific notation to normal ?

Hell friends,

I wrote a script gets the summation of particular column using awk.
The awk output is given in scientific notation. How do I convert the scientific notation to normal.

My awk syntax : awk '{sum += $2} END { printf sum }' temprep.txt

Out put is like 1.5365e+07
I want it as 15365000

Please give me a suggestion.

Thanks
Mahesh
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 01-05-2006
Registered User
 

Join Date: Nov 2003
Location: Minnesota
Posts: 387
When I check man awk in Solaris it says there is a built in variable called OFMT that controls the output format of numbers. You could try setting that to a different format. Also, it says after the printf you can specify the format, check man printf for details on that. I would guess printf %8d sum would work for your example.
Reply With Quote
  #3 (permalink)  
Old 01-05-2006
linuxpenguin's Avatar
Registered User
 

Join Date: May 2002
Location: India
Posts: 295
exactly,
awk '{sum += $2} END { printf ("%8d\n", sum) }' temprep.txt
__________________
War doesnt determine who is right, it determines who is left
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:54 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0