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.

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.

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.

Hi ssunda6,

Could you tell me how u handled this issues.

Thanks in Advance.

Regards,
Sreekanth