title: Is there any command to do fuzzy matching in Linux based on multiple columns
body: <p>I have two csv file. 
  File 1 </p>
  
  <pre><code>D,FNAME,MNAME,LNAME,GENDER,DOB,snapshot
  2,66M,J,Rock,F,1995,201211.0
  3,David,HM,Lee,M,,201211.0
  6,66M,,Rock,F,,201211.0
  0,David,H M,Lee,,1990,201211.0
  3,Marc,H,Robert,M,2000,201211.0
  6,Marc,M,Robert,M,,201211.0
  6,Marc,MS,Robert,M,2000,201211.0
  3,David,M,Lee,,1990,201211.0
  5,Paul,ABC,Row,F,2008,201211.0
  3,Paul,ACB,Row,,,201211.0
  4,David,,Lee,,1990,201211.0
  4,66,J,Rock,,1995,201211.0
  </code></pre>
  
  <p>File 2 </p>
  
  <pre><code>PID,FNAME,MNAME,LNAME,GENDER,DOB
  S2,66M,J,Rock,F,1995
  S3,David,HM,Lee,M,1990
  S0,Marc,HM,Robert,M,2000
  S1,Marc,MS,Robert,M,2000
  S6,Paul,,Row,M,2008
  S7,Sam,O,Baby,F,2018
  </code></pre>
  
  <p>What I want to do is to use the crosswalk file, File 2, to back out those observations' PID in File 1 based on Columns FNAME,MNAME,LNAME,GENDER, and DOB. Because the corresponding information in observations of File 1 is not complete, I'm thinking of using fuzzy matching to back out their PID as many as possible (of course the level accuracy should be taken into account). For example, the observations with FNAME "Paul" and LNAME "Row" in File 1 should be assigned the same PID because there is only one similar observation in File 2. But for the observations with FNAME "Marc" and LNAME "Robert", <code>Marc,MS,Robert,M,2000,201211.0</code> should be assigned PID "S1", <code>Marc,H,Robert,M,2000,201211.0</code> PID "S0" and <code>Marc,M,Robert,M,,201211.0</code> either "S0" or "S1". </p>
  
  <p>Since I want to compensate File 1's PID as many as possible while keeping high accuracy, I consider three steps. First, use command to make sure that  if and only if those information in FNAME,MNAME,LNAME,GENDER, and DOB are all completely matched, observations in File 1 can be assigned a PID. The output should be </p>
  
  <pre><code>D,FNAME,MNAME,LNAME,GENDER,DOB,snapshot,PID
  2,66M,J,Rock,F,1995,201211.0,S2
  3,David,HM,Lee,M,,201211.0,
  6,66M,,Rock,F,,201211.0,
  0,David,H M,Lee,,1990,201211.0,
  3,Marc,H,Robert,M,2000,201211.0,
  6,Marc,M,Robert,M,,201211.0,
  6,Marc,MS,Robert,M,2000,201211.0,
  3,David,M,Lee,,1990,201211.0,
  5,Paul,ABC,Row,F,2008,201211.0,
  3,Paul,ACB,Row,,,201211.0,
  4,David,,Lee,,1990,201211.0,
  4,66,J,Rock,,1995,201211.0,
  </code></pre>
  
  <p>Next, write another command to guarantee that while DOB information are completely same, use fuzzy matching for FNAME,MNAME,LNAME,GENDER to back out File 1's observations' PID, which is not identified in the first step. So the output through these two steps is supposed to be </p>
  
  <pre><code>D,FNAME,MNAME,LNAME,GENDER,DOB,snapshot,PID
  2,66M,J,Rock,F,1995,201211.0,S2
  3,David,HM,Lee,M,,201211.0,
  6,66M,,Rock,F,,201211.0,
  0,David,H M,Lee,,1990,201211.0,S3
  3,Marc,H,Robert,M,2000,201211.0,S0
  6,Marc,M,Robert,M,,201211.0,
  6,Marc,MS,Robert,M,2000,201211.0,S1
  3,David,M,Lee,,1990,201211.0,S3
  5,Paul,ABC,Row,F,2008,201211.0,S6
  3,Paul,ACB,Row,,,201211.0,
  4,David,,Lee,,1990,201211.0,S3
  4,66,J,Rock,,1995,201211.0,S2
  </code></pre>
  
  <p>In the final step, use a new command to do fuzzy matching for all related columns, namely FNAME,MNAME,LNAME,GENDER, and DOB to compensate the remained observations' PID. So the final output is expected to be </p>
  
  <pre><code>D,FNAME,MNAME,LNAME,GENDER,DOB,snapshot,PID
  2,66M,J,Rock,F,1995,201211.0,S2
  3,David,HM,Lee,M,,201211.0,S3
  6,66M,,Rock,F,,201211.0,S2
  0,David,H M,Lee,,1990,201211.0,S3
  3,Marc,H,Robert,M,2000,201211.0,S0
  6,Marc,M,Robert,M,,201211.0,S1
  6,Marc,MS,Robert,M,2000,201211.0,S1
  3,David,M,Lee,,1990,201211.0,S3
  5,Paul,ABC,Row,F,2008,201211.0,S6
  3,Paul,ACB,Row,,,201211.0,S6
  4,David,,Lee,,1990,201211.0,S3
  4,66,J,Rock,,1995,201211.0,S2
  </code></pre>
  
  <p>I need to keep the order of File 1's observations so it must be kind of leftouter join. Because my original data size is about 100Gb, I want to use Linux to deal with my issue. 
  But I have no idea how to complete the last two steps through <code>awk</code> or any other command in Linux. Is there anyone who can give me a favor? Thank you.</p>