title: awk or sed help for munging first line of a CSV or TSV file
body: <p>I was messing around with awk because I think it's far simpler to munge the header of a tab delimited or csv file with this tool.. </p>
  
  <p>I have two types of files (either comma, or tab delimited) and all I would like to do is to modify the header (NR =1) to:</p>
  
  <ol>
  <li>lowers the case of all the words </li>
  <li>replace any spaces with underscores for each
  field name.. Ex. changing <em>Cancer Type</em> bellow to *cancer_type*</li>
  </ol>
  
  <blockquote>
    <p>Cancer Type, Assembly Version, Chromosome, Chromosome
    start, Chromosome end</p>
  </blockquote>
  
  <p>All I've managed to do so far is to list the first line</p>
  
  <blockquote>
    <p>awk 'NR == 1' test2.csv</p>
  </blockquote>
  
  <p>Well I'm at a loss. In any case I'll probably run this script (sed or awk) prior to doing some downstream modifications.</p>
  
  <p>Any help (or pointing me to a good tutorial/one liners) would be much appreciated.</p>
  
  <p>EDIT</p>
  
  <p>Hi I should edit to clarify this. 
  I will be taking starting with a file, and ending with the same file but with the header changed. </p>
  
  <p>I could get two versions of the file.</p>
  
  <p><em><strong>The CSV</em></strong></p>
  
  <blockquote>
    <p>Cancer Type, Assembly Version, Chromosome, Chromosome start,
    Chromosome end</p>
  </blockquote>
  
  <p><strong>After:</strong></p>
  
  <blockquote>
    <p>cancer_type, assembly_version, chromosome, chromosome_start,
    chromosome_end</p>
  </blockquote>
  
  <p><em><strong>The TSV</em></strong></p>
  
  <blockquote>
    <p>Cancer Type\t Assembly Version\t Chromosome\t Chromosome start\t
    Chromosome end</p>
  </blockquote>
  
  <p><strong>After:</strong></p>
  
  <blockquote>
    <p>cancer_type\t assembly_version\t chromosome\t chromosome_start\t
    chromosome_end</p>
  </blockquote>
  
  <p>Having said that I think approaches are almost working..</p>
  
  <p><strong>EDIT 2</strong>
  The os is OS X 10.7.+</p>