I have a shell script to run several times a .c program ('switch') which admit 3 input paramenters.
I want to run the program 4 times passing values {4,16,32,64}, and for parameters
{0.1,0.2,.3,.4,.5,.55,.575,.6,.625,.65,.7,.75,.8,.9}, building a table of average and confidence interval.
The script is the following
#!/bin/bash
if [ -e salida.txt ]; then
# echo "File exists"
rm salida.txt
fi
touch salida.txt
touch sal1.txt
touch sal2.txt
touch sal3.txt
touch sal4.txt
touch salida.txt
num=1000000
stud=3.182
for j in {0.1,0.2,.3,.4,.5,.55,.575,.6,.625,.65,.7,.75,.8,.9}
do
rm sal1.txt sal2.txt sal3.txt sal4.txt
for i in {4,16,32,64}
do
margen=0
sum=0
avg=0
for k in {1..4}
do
a$k=$((`./switch -N$i -r$j -n$num`))
sum=$((sum + a$k))
done
avg=$((sum/4))
dvt=0
for k in {1..4}
do
dvt=$((dvt + (a$k - $avg)*(a$k - $avg)))
done
dvt=$((dvt /3))
dvt=$((echo `sqrt($dvt) | bc -l`))
margen=$((dvt*$stud/2))
echo $avg $margen >> sal$i.txt
done
join sal1.txt sal2.txt sal3.txt sal4.txt >> salida.txt
done
Nevertheless is giving me error in line 27
a$k=$((`./switch -N$i -r$j -n$num`))
and lines
dvt=$((echo `sqrt($dvt) | bc -l`))
margen=$((dvt*$stud/2))
What am I doing wrong?