title: find if filename contains a certain string in bash script
body: <p>I have a bunch of output files in a directory, such as: a.out, b.out c.out, etc.</p>
  <p>I want to search through the output files and if the output <em>file name</em> contains a certain string (such as &quot;a&quot;), then it will print the corresponding output file &quot;a.out&quot; to screen.</p>
  <p>After I cd-ed into the output files directory, here's my code:</p>
  <pre><code>OUT_FILE=&quot;*.out&quot;
  OT=$OUT_FILE
  STRING=&quot;a&quot;
  
  for file in &quot;$OT&quot;;do
    if [[$file == *&quot;$STRING&quot;*]];then
      echo $file
    fi
  done
  </code></pre>
  <p>The error I received is [[*.out: command not found. It looks like $file is interpreted as $OT, not as individual files that matches $OT.</p>
  <p>But when I removed the if statement and just did a for-loop to echo each $file, the output gave me all the files that ended with .out.</p>
  <p>Would love some help to understand what I did wrong. Thanks in advance.</p>