Help with Round Up with 2 decimal point at specific column

Input file:

USA 20.5683
UK 3.54221
Japan 2.54001
China 2.50897
Germany 2.05816
.
.

Desired output file:

USA 20.57
UK 3.54
Japan 2.54
China 2.51
Germany 2.06
.
.

Command try:

awk '{printf("%.2f\n", $2)}' Input_File > Output.tmp1
awk '{print $1"\t"}' Input_File > Output.tmp2
paste -d ' ' Output.tmp2 Output.tmp1

I able to get what I want, but the way I did.
It seems like not so "nice" :frowning:
Thus just wonder whether how to specific just do 2 decimal point at specific column.

Thanks.

Try

awk '{print $1, $2+0}' OFMT="%.2f" file
USA 20.57
UK 3.54
Japan 2.54
China 2.51
Germany 2.06
1 Like

Or

awk '{$2+=0}1' CONVFMT="%.2f" file
2 Likes