title: select files from a list of files with a pattern
body: <p>I have a list of files, which was created using list.files:</p>
  
  <pre><code>filesxx&lt;-list.files(pattern="0-4000")
  </code></pre>
  
  <p>obtainig a list like the following one:</p>
  
  <pre><code>  [1] "Alta Guajira Coord &amp; elevation TS 0-4000.txt"     "Baja Guajira Coord           &amp; elevation TS 0-4000.txt"    
    [3] "Bajo Meta Coord &amp; elevation TS 0-4000.txt"        "Rio Arauca Coord &amp; elevation TS 0-4000.txt"      
    [5] "Rio Catatubo Coord &amp; elevation TS 0-4000.txt"     "Rio Cesar Coord &amp; elevation TS 0-4000.txt"       
    [7] "Rio Sogamoso Coord &amp; elevation TS 0-4000.txt"     "Rio Tomo Coord &amp; elevation TS 0-4000.txt"        
    [9] "Sabana de Bogota Coord &amp; elevation TS 0-4000.txt" "Total Area Coord &amp; elevation TS 0-4000.txt"  
  </code></pre>
  
  <p>and from this list I want create a loop that will select one of this files depending on the loop variable (a) wich will be a pattern in the name, for example the variable (a) will be: "Alta Guajira" and in the next cycle "Rio Tomo".. etc</p>
  
  <p>How can I do this, how to chose a file with a pattern from a list of files already made?
  I think the function <code>Shopt</code> is more to exclude patterns and maybe the function <code>find</code> could work but after looking for some similar case I havent found the answer.</p>