The awk subtraction giving exponential values.Please help resolve it

Hi friends,
I have a file list1 which has these 2 columns like

616449 0
434453 1
2151083 0
2226536 0
2132382 0
2136814 0

I have to put the result of col1 -col2 into another file list2 linewise.

e.g. It gives the below result if use the below code:

awk '{ print $1 - $2 }' list1 > list2

616449
434453
2.15108e+06 
2.22654e+06 
2.13238e+06 
2.13681e+06 

I don't want the exponential values :frowning:
The problem with my code is that it turns the subtraction result into exponential for values greater than 6 digits. How should i modify the awk command (using some formatting features...i tried it but no success) to get the result in the format like given below

616449
434453
2151083
2226536 
2132382
2136814

Also if i try to convert the above exponential values to integer i use some values like 2.15108e+06 becomes 2151080 instead of required 2151083.

For now i have used the below workaround ,
But can anyone please tell me how to modify my above awk syntax to achieve it.

while read line
 do
 var1=`echo $line | awk '{ print $1}'`
 var2=`echo $line | awk '{ print $2}'`
 y=`expr $var1 - $var2`
 echo $y >> list2
done < list1

I have searched this forum number of times for this ,but no success still.:frowning:

Regds,
Kunwar

awk '{ printf "%.0f\n", $1 - $2 }' list1
1 Like

awesome man!!thank you so much..it works perfect.:slight_smile: