Multiplying the decimals in the column

Viewed 19

I want to multiply only the second column by 27.211396132 . I use

awk '{$2=$2*27.211396132 ; print }' input file > output file

The result is wrong . I want the answer to be like 5 -76308.842049 ( for the first line). Please help me.

input file

output file

1 Answers

Use printf see here

echo "5 -2804.297202496805723" | awk ' { $2 = $2*27.211396132 ; printf "%s %0.8f\n", $1, $2 } '


5 -76308.84204900
Related