如何用脚本实现数字的四舍五入

如何用脚本实现数字的四舍五入

怎么编写数字的四舍五入啊?
比如:

0.22222=0.222
0.22299=0.223

请求大家的帮助
谢谢
echo 0.22299 |awk '{ printf "%.3f\n", $1 }'
0.223

echo 0.22222 |awk '{ printf "%.3f\n", $1 }'
0.222
Think you very much.

Now I have a better method to get it.
#printf $.3f 0.222999
#printf $.3f 0.222333

The above two commands work well. And thank you for your answer.
我脑子进水了。。

当初考虑的是怎么四舍五入到前一位

awk '{ printf "%." length($1)-index($1,".")-1 "f\n", $1 }'

如果是固定位数,那么printf更直接了。