title: Unix Scripting - Division
body: <p>I'm building a calculator in the bash shell, but I'm having trouble with division. I've tried adding brackets $(( )) around the entire line and then, only surrounding the two operands, but the total remain incorrect. What am I doing wrong?</p>
  <pre><code>#!/bin/bash
  
  # Read user input
  echo &quot;Enter operand:&quot;
    read num1
  echo &quot;Enter operator:&quot;
    read operator
  echo &quot;Enter operand:&quot;
    read num2
  
  case $operator in
          +) total=`echo $num1 + $num2 | bc`;;
          -) total=`echo $num1 - $num2 | bc`;;
          *) total=`echo $num1 *\ $num2 | bc`;;
          /) total=`echo scale=2; $(( $num1 / $num2 )) | bc`;;
  esac
  echo &quot;Result: $num1 $operator $num2 = $total&quot;
  </code></pre>