Is there a way that i can get something like this to work:
Number=`expr 80 \* 10.69`
i.e. To multiply an integer by a decimal or a decimal by a decimal etc...?
thanks
Is there a way that i can get something like this to work:
Number=`expr 80 \* 10.69`
i.e. To multiply an integer by a decimal or a decimal by a decimal etc...?
thanks
One approch among many...
n=$(echo |awk '{ print 80*10.69}')
Thanks. How could i do something like this:
Number=$(echo | awk '{ print $TEST*10.69}')
where $TEST is some integer?
Use "bc" here:
$ Number=`echo 80 \* 10.69 |bc`; echo $Number
855.20
This gives me an error:
line 34: bc: command not found
Check whether "bc" is there in your machine or not.
It should be here : /usr/bin/bc (check with command: "whereis bc", check your PATH also to execute bc),
Hope this helps
not on my machine
is there some other way i can do this. i realise that it is really simple so there must be another easy way
Here is the solution to pass variable for the above awk computation:
$ S=80; Number=`echo |awk '{ print "'"$S"'"*10.69}'` ; echo $Number
855.2
** Mind this -> "'" (double quote-single quote-double quote)
//Jadu
excellent:)
thanks JADUKS - you are genius
You can do it this way....
rather than putting "double quote-single quote-double quote"
S=80; Number=`echo |awk -v var1=$S '{ print var1*10.69}'` ; echo $Number
Ya, thats another way of passing variables to awk, awk -v xx=$....