Skip to content
Advertisement

How to format decimal space using awk in linux

original file :

JavaScript

now i need to control third columns with 6 decimal space

after i tried awk {'print $1,$2; printf "%.6ft",$3'} but the output is not what I want

result :

JavaScript

that’s weird , how can I do that will just modify third columns

Advertisement

Answer

Your print() is adding a newline character. Include your third field inside it, but formatted. Try with sprintf() function, like:

JavaScript

That yields:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement