I have a csv file that contains hundreds of columns. I would like to subtract the value of a specific column from a static number and then print the entire line. The values of that column are long floats. When I do the subtraction awk automatically converts the result to scientific format. I could use printf to get the standard representation but I need to get the entire row and the fields of each row are too many.

Is there a way to avoid this automatic conversion or at least to bypass it?

1 Answer 1


From man awk:

A numeric expression is converted to string by replacing expr with sprintf(CONVFMT, expr), unless expr can be represented on the host machine as an exact integer then it is converted to sprintf("%d", expr). Sprintf() is an AWK built-in that duplicates the functionality of sprintf(3), and CONVFMT is a built-in variable used for internal conversion from number to string and initialized to "%.6g". Explicit type conversions can be forced, expr "" is string and expr+0 is numeric.

So you can arrange CONVFMT variable on the beginning or format field.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .