title: [: -gt: unary operator expected
body: <p>I don't write a lot of Bash, so I'm a bit stumped as to how to fix this. I need to check whether a value returned from a command is greater than <code>x</code>. When it runs though I get <code>[: -gt: unary operator expected</code> which I'm unable to fix.</p>
  
  <p>Here is my script,</p>
  
  <pre><code>#!/bin/sh
  ERROR=0
  PHPCPDLevel=100
  
  # PHPCPD
  echo "PHP CopyPaste Detection (Limit is at least ${PHPCPDLevel}%"
  PHPCPD="phpcpd ."
  if [[ `echo $PHPCPD | grep "%" | cut -d'.' -f1` -gt "$PHPCPDLevel" ]]
    then
      echo $PHPCPD
      ERROR=1
    else
      echo "... -&gt; Only `echo $PHPCPD | grep "%" | cut -d'.' -f1`%"
  fi
  
  echo "Finished!"
  exit $ERROR
  </code></pre>
  
  <p><strong>Update:</strong>
  I think I've done it:</p>
  
  <pre><code>#!/bin/sh
  ERROR=0
  PHPCPDLevel=25
  
  # PHPCPD
  echo "PHP CopyPaste Detection (Limit is at most ${PHPCPDLevel}%)"
  PHPCPD="phpcpd ."
  PERCENTAGE=$($PHPCPD | grep "%" | cut -d'.' -f1)
  if [ ${PERCENTAGE} -gt ${PHPCPDLevel} ]
    then
      echo $PHPCPD
      ERROR=1
    else
      echo "Only $PERCENTAGE%"
  fi
  
  exit $ERROR
  </code></pre>