title: How can I test if a variable contains a string in a bash script without getting the "command not found" error?
body: <p>I keep getting a "command not found" error after checking a variable for the substring <code>.txt</code>.</p>
  
  <p>Here's a simple version of my script.</p>
  
  <p>myscript.sh</p>
  
  <pre><code>#!/bin/sh
  if [["$1" == *.txt]]
      then
      echo $1
  fi
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>&gt; ./myscript.sh argument.txt
  ./myscript.sh: line 2: [[argument.txt: command not found]]
  </code></pre>