title: Merge and split, using csplit in bash
body: <p>I'm merging three three files (ls -l):</p>
  
  <pre><code>-rw-rw-r-- 1 kacper kacper 1839510 sie 13 14:27 A.jpg
  -rw-rw-r-- 1 kacper kacper 2014809 sie 13 14:27 B.jpg
  -rw-rw-r-- 1 kacper kacper 1277047 sie 13 14:27 C.pdf
  </code></pre>
  
  <p>into one file (merged) in bash using:</p>
  
  <pre><code>cat A.jpg &gt;&gt; merged 
  echo $SEPARATOR &gt;&gt; merged 
  cat B.jpg &gt;&gt; merged 
  echo $SEPARATOR &gt;&gt; merged 
  cat C.pdf &gt;&gt; merged
  </code></pre>
  
  <p>where:</p>
  
  <pre><code>SEPARATOR=PO56WLH82SN1ZS5QH5EU9FOZVLBRLHAGHO3D5KOUSPMS6KYSFAYN2DBL
  </code></pre>
  
  <p>Next I'm splitting the merged file into three parts using:</p>
  
  <pre><code>csplit --suppress-matched merged --prefix="PART_" '/'$SEPARATOR'/' {*}
  </code></pre>
  
  <p>this produces PART_00, PART_01, PART_02 (ls -l):</p>
  
  <pre><code>-rw-rw-r--  1 kacper kacper 1839398 sie 13 18:41 PART_00
  -rw-rw-r--  1 kacper kacper 2014507 sie 13 18:41 PART_01
  -rw-rw-r--  1 kacper kacper 1277047 sie 13 18:41 PART_02
  </code></pre>
  
  <p>PART_00 and PART_01 are JPG files and can be properly displayed. PART_02 is a PDF file and it can be opened and viewed. So, at first glance this looked to me like success.</p>
  
  <p>The problem is that the size of PART_00 (1839398 bytes) is slightly smaller then A.jpg (1839510 bytes). The same goes for the other files (PART_01, B.jpg and PART_02, C.pdf). After checking the files byte by byte using </p>
  
  <pre><code>cmp
  </code></pre>
  
  <p>the pairs of files are exactly the same up to the point when one of them ends.</p>
  
  <p>Anyone know why this is the case? Advice would be greatly appreciated.</p>