title: Bash: Trouble when using cat for a lot of files
body: <p>For each set of parameters I try to merge 400 data files with 13 lines each to a large one like this:</p>
  
  <pre><code>folders=(*/)
  for folder in ${folders[@]}; do
      #FIND SIGMA
      sig0=${folder#*sig}
      sig=${sig0%amax*}
      #MERGE
      cat sig${sig}amax0.6_incr0.1/tau*.dat &gt; merged_sigma${sig}amax0.6_incr0.1.dat
  done
  </code></pre>
  
  <p>It's easy math that a merged file should have 5200 lines, but it doesn't.<br>
  Instead, each merged file has a different number of lines, varying between about 3100 and 5000.</p>
  
  <p>I've checked that all the <code>tau*.dat</code> files exist, are not empty and have exactly 13 lines.
  There is no problem with missing line breaks at the ends of the small files. In the merged file all lines have the same length. Just some - and it seems to me in a random manner - are missing.</p>
  
  <p>I've read somewhere that the total number of characters in all the file names together mustn't exceed 32767 characters. However, even when taking into account that the file names are not <code>tau*.dat</code> but <code>sig0.10amax0.1_incr0.1/tau27.0_sigma0.10__-0.6-0.6_0-0_0.1.dat</code> I only have no more than 25000 characters for each cat command.</p>