title: find common elements in >2 files
body: <p>I have three files as shown below</p>
  
  <p>file1.txt </p>
  
  <pre><code>"aba" 0 0 
  "aba" 0 0 1
  "abc" 0 1
  "abd" 1 1 
  "xxx" 0 0
  </code></pre>
  
  <p>file2.txt</p>
  
  <pre><code>"xyz" 0 0
  "aba" 0 0 0 0
  "aba" 0 0 0 1
  "xxx" 0 0
  "abc" 1 1
  </code></pre>
  
  <p>file3.txt</p>
  
  <pre><code>"xyx" 0 0
  "aba" 0 0 
  "aba" 0 1 0
  "xxx" 0 0 0 1
  "abc" 1 1
  </code></pre>
  
  <p>I want to find the similar elements in all the three files based on first two columns. To find similar elements in two files i have used something like</p>
  
  <pre><code>awk 'FNR==NR{a[$1,$2]++;next}a[$1,$2]' file1.txt file2.txt 
  </code></pre>
  
  <p>But, how can we find similar elements in all the files, when the input files are more than 2?
  Can anyone help?</p>
  
  <p>With the current awk solution, the output ignores the duplicate key columns and gives the output as</p>
  
  <pre><code>"xxx" 0 0
  </code></pre>
  
  <p>If we assume the output comes from file1.txt, the expected output is:</p>
  
  <pre><code>"aba" 0 0 
  "aba" 0 0 1
  "xxx" 0 0 
  </code></pre>
  
  <p>i.e it should get the rows with duplicate key columns as well.</p>