title: BASH: Compare related entries in multiple files
body: <p>I have 3 files with md5 sums that I would like to compare. I was thinking of initially sorting the files and comparing them line by line. However, there are occasionally missing entries in one or more files. Fortunately, the package names are included with the md5 sums on the same row like this:</p>
  
  <pre><code>FILE 1: 
  pkg1 md5sum1
  pkg2 md5sum2 (this one might not be located in FILE 2, but is in FILE 3, as an example) 
  etc....
  </code></pre>
  
  <p>How can I compare the md5sums of the packages that are present in ALL files (printing "match" or "mismatch") and output "missing" if not found in all files? </p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>A sample output could be: </p>
  
  <pre><code>pkg1 w14r1w4r w14r1w4r w14r1w4r match
  pkg2 t432t432 t432t432 t432t432 match
  pkg3 r321     asdf     asdf     mismatch
  pkg4 12341234                   mismatch
  </code></pre>
  
  <p>The first column is a list of all package names
  The second, third, and fourth show the md5 sums for files 1-3
  The last column shows match only if all 3 are the same</p>
  
  <p><strong>EDIT2:</strong></p>
  
  <p>If the 1st input file had an extra column (3rd), could we add this to the output file?</p>
  
  <pre><code>pkg1 md5sum1 string1  
  pkg2 md5sum2 string2 
  </code></pre>
  
  <p>The output would then be </p>
  
  <pre><code>pkg1 string1 w14r1w4r w14r1w4r w14r1w4r match
  pkg2 string2 t432t432 t432t432 t432t432 match
  pkg3 string3 r321     asdf     asdf     mismatch
  pkg4 string4 12341234                   mismatch
  </code></pre>