title: How to check whether a string starts with a substring
body: <p>I am writing a very simple script which copies a file to a path provided by the user as a parameter and I would like to make sure the path starts with <em>/var/log/messages</em>.</p>
  
  <p>So I've written this:</p>
  
  <pre><code>if [[ $2 -ne /var/log/messages/* ]]
  then
    echo "Incorrect path, must be under /var/log/messages/"
    exit
  fi
  </code></pre>
  
  <p>But it doesn't seem to work.</p>
  
  <p>What am I doing wrong?</p>