title: Get list of files with partial match on numbers range in bash 4
body: <p>I've got a large number of files in the following format:</p>
  
  <pre><code>tile_4665_411_1000575_w10#aa.til  tile_6535_366_1100695_w30#ab.til
  tile_4665_411_1000576_w10#aa.til  tile_6535_366_1100712_w30#aa.til
  tile_4665_411_1001046_w10#aa.til  tile_6535_366_1100736_w25#aa.til
  tile_4665_411_1001097_w10#aa.til  tile_6535_366_1100742_w25#aa.til
  tile_4665_411_1001120_w10#aa.til  tile_6535_366_1100742_w25#ab.til
  tile_4665_411_1001192_w10#aa.til  tile_6535_366_1100742_w25#ac.til
  tile_4665_411_1100653_w15#aa.til  tile_6535_366_1100742_w25#ad.til
  tile_4666_411_1000468_w10#aa.til  tile_6535_366_1100742_w25#ae.til
  tile_4666_411_1000510_w10#aa.til  tile_6535_366_1100742_w25#af.til
  </code></pre>
  
  <p>and so on. These are the results from splitting large files into smaller files. Hence the naming convention (tile_<strong>largeFile</strong>_<strong><em>smallFile</em></strong>_uniqueidentifier_weight#split.til). Each individual <strong><em>smallFile</em></strong> is nested within <strong>largeFile</strong> (imagine splitting a square into subsquares each with the same size).</p>
  
  <p>The next step is to <strong><em>cat</em></strong> all separate files belonging to largeFile_smallFile into one file as follows:</p>
  
  <p>tile_<strong>largeFile</strong>_<strong><em>smallFile</em></strong>.tile</p>
  
  <p>e.g. <code>cat tile_4665_411_*.til &gt; tile_4665_411.tile</code></p>
  
  <p>We have room for 6700 potential <strong><em>smallFiles</em></strong>, though about 30% of them are never created. At the moment, we're starting a job for each potential small_File and return out of the process if there is no such file. </p>
  
  <pre><code>numberofFiles=6700
  listOfTiles==$(ls tile_*.til)
  </code></pre>
  
  <p>And then loop from 1 to 6700 nd grabbing the corresponding pattern:</p>
  
  <pre><code>PATTERN=$(ls tile_*_$COUNTER_*.til
  #split filenames to get largeFile
  cat $PATTERN &gt; tile_largeFile_$COUNTER.tile
  </code></pre>
  
  <p>While this approach works, it is obviously not elegant and might lower our priority for execution (due to the number of processes we are requesting etc.).</p>
  
  <p>Is there a smarter way to get a list of the individual small tiles that are actually in the folder?
  I.e. something like:</p>
  
  <pre><code>numberofFiles=$(ls tile_*_{1..6700}_*.til) #unique smallFile numbers that are (potentially) between 1 and 6700
  </code></pre>
  
  <p>In a sense, I'd like to get the unique number of smallFile Id'S from a very large list of files.</p>
  
  <p>Any help is super appreciated!</p>
  
  <p>Cheers</p>