Need to be able to round numbers in bash to the nearest whole number? You can use a single line of code in AWK to do the job. For example, the following code will make the number 29.498398 round up to 29.50:
$ echo 29.498398 | awk '{ rounded = sprintf("%.2f", $1); print rounded }'
29.50
Thursday, January 22, 2009
Rounding Numbers
Posted by techgeek168 at 8:44 AM
Labels: CygwinAwkCronSed
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment