removing leading zeros for a decimal column in a file which has string & decimal values
,,,,,6630140,XXXXXXXXXXXXXXX, 0020.00,USA
,,,,,6630150,XXXXXXXXXXXXXXXL (xyz, 0010.00,USA
,,,,,6630150,XXXXXXXXXXXXXXX(xyz), 1300.00,USA
My file contains 9 columns. Out 9 columns, 8th column contains the decimal/integer values.
In my requirement, i just need to remove the leading zero from the integer column. say for example
0020.00 should be converted into 20.00
0010.00 should be converted into 10.00
1300.00 should be the same 1300.00
I tried the below command in unix. But, it didn't work for my requirement.
sed 's/^[0].*//' sample.txt
It works well for 0020 or 0010. The above command converts 0020 to 20 and 0010 to 10. But, when there is a fraction in the number, the above one is not working.
Any suggestions?
Thanks,
N