title: what is the error in mathematical expressions in the code
body: <p>what is the error in the following code. The mathematical expressions seems to be failing
  The aim of the code is to read the number from file.txt and calculate mean and variance</p>
  
  <p>Mean</p>
  
  <pre><code> #!/bin/bash
  if [ $# -ne 1 ]; then
          echo "Usage: \"$0\" &lt;filename&gt;"
          exit
  fi
  
  if [ ! -f $1 ]; then
          echo "$1 file not found."
          echo "Usage: $0 &lt;filename&gt;"
          exit
  fi
  
  sum=0
  sumSq=0
  count=0
  arq=$1
  
  while read line
  do
          num=`echo ${line//[^0-9]/ }`
          sum=`expr $sum + $num`
          sumSq= `expr $sumSq + $num * $num]`
          count=`expr $count + 1`
  done &lt; "$arq"
  
  if [ "$count" != 0 ]
  then
          mean=`expr $sum / $count`
          variance=`expr [$sumSq - [$mean * $sum] / $count]`
          printf "Sum= \"$sum\" \n Count= \"$count\"  \n mean= \"$mean\"  \n sumSq= \"$sumSq\" \n variance= \"$variance\""
          exit 0
  else
          printf "Sum= \"$sum\" \n Count= \"$count\"  \n Avg= undefined"
          exit 0
  fi
  </code></pre>
  
  <p>file.txt </p>
  
  <pre><code>Current Offset from Master : 10
  Current Offset from Master : 20
  </code></pre>
  
  <p>sh mean file.txt</p>