linux - Decrease Decimals in Fourth Column In a Text File -
i have text file fourth column contains numbers many decimal places. need reduce places 0.1 decimal place.
data:
2015041416 kbos tmp2m 62.034 2015041417 kbos tmp2m 65.0826 2015041418 kbos tmp2m 66.7278 2015041419 kbos tmp2m 67.5033 2015041420 kbos tmp2m 67.1731 2015041421 kbos tmp2m 65.9252 2015041422 kbos tmp2m 62.7644 2015041423 kbos tmp2m 60.8136 2015041500 kbos tmp2m 56.167 2015041501 kbos tmp2m 55.7116 2015041502 kbos tmp2m 51.8512 2015041503 kbos tmp2m 51.6005 2015041504 kbos tmp2m 50.1643 2015041505 kbos tmp2m 49.2167 2015041506 kbos tmp2m 48.273 2015041507 kbos tmp2m 46.6407
awk '{printf "%s %s %s %.1f\n",$1, $2, $3, $4}' file > file2
output file2:
2015041416 kbos tmp2m 62.0 2015041417 kbos tmp2m 65.1 2015041418 kbos tmp2m 66.7 2015041419 kbos tmp2m 67.5 2015041420 kbos tmp2m 67.2 2015041421 kbos tmp2m 65.9 2015041422 kbos tmp2m 62.8 2015041423 kbos tmp2m 60.8 2015041500 kbos tmp2m 56.2 2015041501 kbos tmp2m 55.7 2015041502 kbos tmp2m 51.9 2015041503 kbos tmp2m 51.6 2015041504 kbos tmp2m 50.2 2015041505 kbos tmp2m 49.2 2015041506 kbos tmp2m 48.3 2015041507 kbos tmp2m 46.6
same output bash , without awk:
printf "%s %s %s %.1f\n" $(< file) > file2
Comments
Post a Comment