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 > 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
Numeric Validation sumesh.abraham Shell Programming and Scripting 12 08-04-2008 10:10 AM
Perl code to differentiate numeric and non-numeric input Raynon Shell Programming and Scripting 11 08-04-2007 10:32 AM
Converting exponential values rleebife Shell Programming and Scripting 2 08-02-2007 11:59 PM
Checking numeric value malaymaru Shell Programming and Scripting 6 05-25-2007 08:42 PM
non-numeric argument TiredOrangeCat UNIX for Dummies Questions & Answers 3 02-13-2007 02:37 AM

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 04-24-2008
ssunda6 ssunda6 is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 7
Conversion of Exponential to numeric in awk- not correct output

Hi All,

I have 1 million records file. Using awk, I am counting the number of records. But as the number is huge, after crossing a number, awk is displaying it in exponential format.

At the end, I need to verify this count given by awk with expected count.
But as it is in exponential format, the comparision is failing.

I tried converting the exponential format to numeric using printf("%d,$0) formats , but when converting it is not giving the accurate value.

Say I have 10,93,861 records in the file. Awk is giving following output -> 1.09386e+06

When converting this exponential format to numeric, it is giving the value as10,93,860 which is incorrect.

I dont want to implement this in shell as it takes huge amount of time for the file.

Please help.
Regards,
Ssunda.
  #2 (permalink)  
Old 04-24-2008
robotronic's Avatar
robotronic robotronic is offline Forum Advisor  
Can I play with madness?
  
 

Join Date: Apr 2002
Location: Italy
Posts: 370
You shouldn't use awk if you only need the record count of a file. Use "wc -l filename.txt" instead.

Otherwise, if you make some computations in the awk code, I think that knowing which version of awk on which OS are you using will give us some more info for solving the issue.
  #3 (permalink)  
Old 04-24-2008
ssunda6 ssunda6 is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 7
I am not just taking the count of records. In addition to that I am also doign some processing and validations.

I tried to check the version of awk using
awk -v and
awk --version

but is displaying usage of awk only.

OS is Unix

Regards,
ssunda.
  #4 (permalink)  
Old 09-19-2008
shhrikanth shhrikanth is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 1
Hi ssunda6,

Could you tell me how u handled this issues.

Thanks in Advance.

Regards,
Sreekanth
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 10:41 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