title: prime number function in shell script
body: <p>I am new to Shell script. I have written a function to check weather a number is prime or not but I am getting error of Unary operator expected in if condition. Kindly point out where I have done mistake. </p>
  
  <p>file :fprime.sh</p>
  
  <pre><code> prime ()
   {
  
          n=$1
          t=0
          for i in {2..$n}
          do
          r=`expr $n % $i`
          if [ $r == 0 ]
          then
          t=`expr t + 1`
          fi
          done
          if [ $t == 1 ]
          then
          echo "prime"
          else
          echo "not prime"
          fi
   }
  
  prime
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>~$ ./fprime.sh 5
  
  expr: syntax error
  ./fprime.sh: line 8: [: ==: unary operator expected
  </code></pre>
  
  <p>not prime</p>