title: awk find the closest match of a list in a matrix
body: <p>I look for common elements in two files or which row of a matrix has the most elements from a given row. what I understood until now is how to compare fields. I receive the lines which hold the same value in the same fieldnumber.
  But how can I open the search to the other field numbers?</p>
  
  <pre><code>awk 'NR==FNR{a[$1];next}$1 in a{print $1" "FNR}'   file1 file2 
  104 3
  </code></pre>
  
  <p>Expected output:
  104 3 111 4 117 2 134 2 148 - 156 4 166 4 176 3 186 - 198 1 221 6 236 -
  best match row 4 with 3 elements common.</p>
  
  <pre><code>file 1
  104 111 117 134 148 156 166 176 186 198 221 236
  
  file 2
  102 108 116 124 132 141 151 162 173 185 198 211 
  103 109 117 125 134 143 153 163 175 187 200 213 
  104 110 118 126 135 144 154 165 176 188 201 215 
  105 111 119 127 136 145 156 166 178 190 203 217 
  106 112 120 128 137 147 157 168 179 192 205 219 
  107 113 121 130 139 148 158 169 181 193 207 221 
  108 114 122 131 140 150 160 171 183 195 208 200
  </code></pre>