title: Find file in bash fails
body: <p>I'm doing a script in Bash which aims to clean all the junk files I may have in a directory. I created an array with all the file patterns that I want to remove.</p>
  
  <h3>Example</h3>
  
  <p>Imagine that I have a dir called <code>temp</code> and inside it I have files which match the patterns in the array below</p>
  
  <pre><code>fileJunk=(".inca*" ".cat*" "*Cat%" "*inca*")
  </code></pre>
  
  <p>Then I do a <code>find</code> for each one of the items as below</p>
  
  <pre><code>for j in "${fileJunk[@]}"
  do
      myList=( `find temp -maxdepth 2 -type f -iname $j` )
      for z in "${myList[@]}"
      do
          rm $z &gt;&amp; /dev/null      
          if [ $? -eq 0 ]
          then
              echo -e "SUCCESS: File $j was deleted\n"
          fi
      done        
  done
  </code></pre>
  
  <p>The problem is that the <code>find</code> command finds all the files except the ones that <em>inca</em> should match.</p>
  
  <p>Doing this directly on the command line worked only if I enclosed <code>*inca*</code> with double quotes. So I've changed the array to:</p>
  
  <pre><code>fileJunk=(".inca*" ".cat*" "*Cat%" "\"*inca*\"")
  </code></pre>
  
  <p>This way I'm passing <code>"*inca*"</code> to the <code>find</code> command instead of <code>*inca*</code>. However this only works on the command line, not using the script?</p>
  
  <p>More info
  Just to be clear my question, by the end, is: why when I use the command <code>find</code> in the shell with <code>"*inca*"</code> it works and within the script doesn't ?</p>