I am using awk to simply change some text in a file, while maintaining the values as they are currently in the file.
The problem is a few of the values are changing. the values are maintained if i use %f
- however, i would like to eliminate the unnecessary trailing zero's. This is accomplished for most values when using %g
, but %g
causes a few of the values to convert to scientific numbers, which i do not want.
Is there a way to both print the numbers to the new file without the trailing zero's as well as not convert any numbers to scientific notation?
Examples:
When i apply the following to the file i am changing, using %f
:
(rline == 4) {printf("%f\t %s\n",$1,"gsurf_intercept")}
it results in:
1000000.000000 gsurf_intercept
when i use the %g
option:
(rline == 4) {printf("%g\t %s\n",$1,"gsurf_intercept")}
it results in:
1e+06 gsurf_intercept
what i want is:
1000000 gsurf_intercept
Also, i applying this to 70 lines in the file i'm changing, and i would like the resulting file to produce two columns, each column in alignment. I find that not each item lines up with the one above or below - this happens when the item in the first column is a string and i use %s
for it.