float input

how to input float data type in bash shell programming in linux?
I am new to it so unaware to use the commands plz help me out.
thank you.

Looks..H..Work..

mmm..

Thanks
Sha

Huh :eek: what kind of answer is this?

There are a lot of threads regarding floating arithmetic with shell scripting, search for floating arithmetic.

Regards

My problem is to input float value.
I have done it in this way
#!bin/bash
sum=0.0
read a
sum=`expr $a + $sum | bc`
echo sum
but when i entered float no. then it is giving expr...non numeric argument .
ok
thanx any ways

Hi,

Small correction...

hope this should work...
#!bin/bash
sum=0.0
read a
sum=`echo $a + $sum | bc`
echo $sum

Thanks
Sha

Thanx alot .
That is working.
But sorry I want to ask more
how can we implement end of file command in shell
means I have to insert nos. from user till he presses "ctrl c" and after that display their addition .
How can I do this.
Thanking in anticipation.
Have a good day.

Hi ,

For division,, you can use like this...(using awk)

 echo "test"|awk -v var1=3.3 -v var2=3 '{print var1 / var2}'

Thanks
Sha