I am currently trying to input prices into a .txt file.
So i want it when the user input:1.1
Instead of 1.1
, I want it to become 1.10
instead. As it would look better for the table I am trying to make in the future. I would also like to round up or down if it goes more than 3 decimal places. (Thanks john1024 for the correction)
read x; printf '%.2f\n' "$x"
maybe? Seehelp printf
andman 3 printf
– steeldriver Jan 19 '18 at 03:22x2
:read x; printf -v x2 '%.02f' "$x"
– John1024 Jan 19 '18 at 03:40