title: merge / append files and re-number first column in unix
body: <p>I am many (3 just an example) text files in different directories (3 different names) like following:</p>
  
  <p>Directory: A, file name: run.txt  format: txt tab deliminated </p>
  
  <pre><code>; file one 
  10     0.2   0.5   0.3
  20     0.1   0.6   0.8
  30     0.2   0.1   0.1
  40     0.1   0.5   0.3
  </code></pre>
  
  <p>Directory: B, file name: run.txt  format: txt tab deliminated </p>
  
  <pre><code>; file two 
  10     0.2   0.1   0.2
  30     0.1   0.6   0.8
  50     0.2   0.1   0.1
  70     0.3   0.4   0.4
  </code></pre>
  
  <p>Directory: C, file name: run.txt  format: txt tab deliminated </p>
  
  <pre><code>; file three 
  10     0.3   0.3   0.3
  20     0.3   0.6   0.8
  30     0.1   0.1   0.1
  40     0.2   0.2   0.3
  </code></pre>
  
  <p>I want to combine all three run.txt files into single and renumber the first column. The resulting new file will look like:</p>
  
  <pre><code>; file combined 
  10     0.2   0.5   0.3
  20     0.1   0.6   0.8
  30     0.2   0.1   0.1
  40     0.1   0.5   0.3
  
  50     0.2   0.1   0.2
  70     0.1   0.6   0.8
  90     0.2   0.1   0.1
  110    0.3   0.4   0.4
  
  120    0.3   0.3   0.3
  130    0.3   0.6   0.8
  140    0.1   0.1   0.1
  150    0.2   0.2   0.3
  </code></pre>
  
  <p>This what my codes are at:</p>
  
  <pre><code>cat A/run.txt B/run.txt C/run.txt &gt; combined.txt
  </code></pre>
  
  <p>(1) I do not know how to take care of renumbering by first column</p>
  
  <p>(2) Also I do not how to take care of comment starting with ";"</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Let me be clear about the number scheme:
  A/run.txt, B/run.txt and C/run.txt are actually parallel run to combined into one. 
  so each will have stored samples with run number. However gap can be uneven among the run.</p>
  
  <p>(1) for first file A/run.txt (gap is 10, 20-10, 30-20)</p>
  
  <pre><code>10, 10+10, 20+10, 30+10
  </code></pre>
  
  <p>(2) for second file B/run.txt, starts from 10 but has gap of 20 
  (eg. 30-10, 50-70, 70-50)</p>
  
  <pre><code>40 (from last line of the first file) + 10 (first in file two) = 50, 
   50 + 20 = 70,70 + 20 = 90,  90+ 20 = 110
  </code></pre>
  
  <p>(3) file C/run.txt starts from 10 and increment is 10</p>
  
  <pre><code>110 (last number in file 2) + 10 = 120, 120+ 10 = 130,
   130+10 = 140, 140+10 = 150`
  </code></pre>