Hi,
in my ksh script
expr 22 / 10 results as 2
but the actual result expected in 2.2.
how do i get that result. Please help
Thanks,
Hi,
in my ksh script
expr 22 / 10 results as 2
but the actual result expected in 2.2.
how do i get that result. Please help
Thanks,
When using expr the '/' operation is not divide but returns the quotient. You need to use bc or something similar, for example:
echo "scale=2;22/10" | bc
Hi All,
i tried to assign it by the below way
$ test="scale=2;22/10" | bc
$ echo $test
but i got no output
please let me know ,why it is not getting assigned .. Am i wrong in anthing please let me know.
Thanks in Advance,
Arun
What you are doing here is assigning the 'standard output' of running '"scale=2;22/10" | bc' to the variable 'test'. Unfortunately that is not a valid command and the only output is to standard error. What you need is:
test=`echo "scale=2;22/10" | bc`
echo $test
you can use this syntax also--
awk 'BEGIN{ print (22/10) }'
Thanks
Namish Tiwari