> I have a script that is returning me number varibles with decimal places in them.
> e.g
>
> 129.384756%
> 75.12872%
>
> What bash command would i use to round this above numbers to 2 decimal


Here's a really kludgy, ugly, inelegant (you get the idea) way using bc that worked for me once ...

x=5.345345
y=`echo "scale=2; $x/1" | bc -l`
echo $y

Unfortunately, it truncs instead of rounding.

- Rog ... takes half a cookie

--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to