Runtime error (func=(main), adr=5) : Divide by zero - How to fix?
<p>My shell script is giving the following error: <code>Runtime error (func=(main), adr=5) : Divide by zero</code> 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:</p>

<pre><code>dir=$folder
cd folder

shop1=$1
mean1=4.78
n1=127

shop2=$2
mean2=4.75
n2=324

grep -P -o '(?=&lt;Rating&gt;).*' $hotel1 |
awk '{ sub(/&lt;Overall&gt;/, ""; print }' |
awk '{sum+=$1; sumsq+=$1*$1} END {print sqrt(sumsq/NR - (sum/NR)**2)}'

grep -P -o '(?=&lt;Rating&gt;).*' $hotel2 |
awk '{ sub(/&lt;Overall&gt;/, ""; 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)
</code></pre>

<p>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.</p>