title: Bash: using the result of a diff in a if statement
body: <p>I am writing a simple Bash script to detect when a folder has been modified.</p>
  
  <p>It is something very close to:</p>
  
  <pre><code>ls -lR $dir &gt; a
  ls -lR $dir &gt; b
  
  DIFF=$(diff a b) 
  if [ $DIFF -ne 0 ] 
  then
      echo "The directory was modified"
  </code></pre>
  
  <p>Unfortunately, the if statement prints an error: [: -ne: unary operator expected</p>
  
  <p>I am not sure what is wrong with my script, would anyone please be able to help me?</p>
  
  <p>Thank you very much!</p>
  
  <p>Jary</p>