title: Count files in a directory with filename matching a string
body: <p>The command:</p>
  
  <pre><code>ls /some/path/some/dir/ | grep some_mask_*.txt | wc -l
  </code></pre>
  
  <p>returns the correct number of files when doing this via ssh on bash. When I put this into a .sh Script</p>
  
  <pre><code>iFiles=`ls /some/path/some/dir/ | grep some_mask_*.txt | wc -l`
  echo "iFiles: ${iFiles}"
  </code></pre>
  
  <p>it is always <code>0</code>. Whats wrong here?</p>
  
  <p><strong>Solution:</strong><br>
  When I worked on it I found out that my "wildcard-mask" seems to be the problem. using <code>grep some_mask_ | grep \.txt</code> instead of the single grep above helped me to solve the problem for the first.</p>
  
  <p>I marked the answer as solution which pretty much describes exactly what I made wrong. I'm going to edit my script now. Thanks everyone.</p>