title: Check input for alphanumeric and slashes in Bash?
body: <p>I want to check if the input contains only alphanumeric characters and <code>/</code>slashes. </p>
  
  <p>My code:</p>
  
  <pre class="lang-sh prettyprint-override"><code>if [ ! -z `echo $2 | tr -d "[\/:alnum:]"` ]; then
     echo "Error: input contains non-alphanumeric characters."
     exit 1 
  fi
  </code></pre>
  
  <p>If I type <code>.script.sh /example/test/</code> an error is thrown. Why?</p>