title: How can I compare two 2D-array files with bash?
body: <p>I have two 2D-array files to read with <code>bash</code>.</p>
  
  <p>What I want to do is extract the elements inside both files.</p>
  
  <p>These two files contain different rows x columns such as:</p>
  
  <p><strong>file1.txt (nx7)</strong></p>
  
  <pre><code>NO DESC ID TYPE W S GRADE
  1 AAA 20 AD 100 100 E2 
  2 BBB C0 U 200 200 D 
  3 CCC 9G R 135 135 U1 
  4 DDD 9H Z 246 246 T1 
  5 EEE 9J R 789 789 U1 
  .
  .
  .
  </code></pre>
  
  <p><strong>file2.txt (mx3)</strong></p>
  
  <pre><code>DESC W S 
  AAA 100 100 
  CCC 135 135
  EEE 789 789
  .
  .
  .
  </code></pre>
  
  <p>Here is what I want to do:  </p>
  
  <ol>
  <li><p>Extract the element in DESC column of <strong>file2.txt</strong> then find the corresponding element in <strong>file1.txt</strong>.</p></li>
  <li><p>Extract the W,S elements in such row of <strong>file2.txt</strong> then find the corresponding W,S elements in such row of <strong>file1.txt</strong>.</p></li>
  <li><p>If <code>[W1==W2 &amp;&amp; S1==S2];</code> then <code>echo "${DESC[colindex]} ok";</code> else <code>echo "${DESC[colindex]} NG"</code></p></li>
  </ol>
  
  <p>How can I read this kind of file as a 2D array with bash or is there any convenient way to do that?</p>