My shell script is giving the following error: Runtime error (func=(main), adr=5) : Divide by zero
but I don't see where I could be dividing by zero? I have found other people with similar issues but there solutions are highly specific and can't replicate them within my script. Here is my script:
dir=$folder
cd folder
shop1=$1
mean1=4.78
n1=127
shop2=$2
mean2=4.75
n2=324
grep -P -o '(?=<Rating>).*' $hotel1 |
awk '{ sub(/<Overall>/, ""; print }' |
awk '{sum+=$1; sumsq+=$1*$1} END {print sqrt(sumsq/NR - (sum/NR)**2)}'
grep -P -o '(?=<Rating>).*' $hotel2 |
awk '{ sub(/<Overall>/, ""; print }' |
awk '{sum+=$1; sumsq+=$1*$1} END {print sqrt(sumsq/NR - (sum/NR)**2)}'
md=0.03
d1=0.003
d2=0.0038
d1d2=$(echo "d1 + d2" | bc)
sq=0.069
tstat=$(echo "md / sq" | bc)
My script basically will eventually calculate the t-statistic from my two data files, to do this it first calculates the standard deviation of each file. Thanks for your time.