I'm having a small doubt in shell Scripting
I have a program (a.out) which I run several times and it prints a particular value on to the terminal. I need to write a shell script to capture the output of this program and add the outputs.
I wrote the following script
value=0
total=0
for((i=0;i<10;j++))
do
value=`./a.out $i`
total=`expr $total + $value`
done
echo value is $value total is $total
Here, I run a.out with an argument being the i values. When I run this script, I get the error expr: non-integer argument
The problem here is with value variable. My a.out gives a double as an output and I need to capture this number in a variable.
I'm a newbie in shell scripting, Can some one please help me on this.
i++, notj++, in the for loop. And./a.outisn't giving you a double as output; it's giving you a line of text (which you might then store as a string, which might then be interpreted as a number).