title: Extract columns from a file based on header selected from another file
body: <p>I have the following problem that I want to solve in awk. I have one large text table, comma separated, consisting of 100k rows and 5k cols. The first row is a header and the first column is a record id. I then have a second text file that contains a subset of the headers in the first file. I want to extract all the columns of the first file whose header is contained in the list given in the second file. Here an example of the inputs and the desired output:</p>
  
  <p>DATA.TXT  </p>
  
  <pre><code>   ID, head1, head2, head3, head4  
      1, 25.5, 1364.0, 22.5, 13.2  
      2, 10.1, 215.56, 1.15, 22.2  
  </code></pre>
  
  <p>LIST.TXT  </p>
  
  <pre><code>head1  
  head4  
  </code></pre>
  
  <p>Desired output: </p>
  
  <pre><code>ID, head1, head4  
  1, 25.5, 13.2  
  2, 10.1, 22.2
  </code></pre>
  
  <p>Anybody can give me some advice on how to solve this problem in awk or however through unix scripting? Thanks in advance for any help!</p>