title: Retrieve specific field based on structure of file, awk
body: <p>MyFile:</p>
  
  <pre><code>    1       Cufflinks       exon    162752  163607  .       +       .       gene_id "XLOC_000001"; transcript_id "TCONS_00000001"; exon_number "1"; oId "CUFF.1.1"; class_code "u"; tss_id "TSS1";
      1       Cufflinks       exon    177199  177399  .       +       .       gene_id "XLOC_000002"; transcript_id "TCONS_00000002"; exon_number "1"; oId "CUFF.3.1"; class_code "u"; tss_id "TSS2";
      1       Cufflinks       exon    178775  179390  .       +       .       gene_id "XLOC_000003"; transcript_id "TCONS_00000003"; exon_number "1"; gene_name "ENSORLG00000000007"; oId "CUFF.15.1"; nearest_ref "ENSORLT00000000006"; class_code "s"; tss_id "TSS3";
      1       Cufflinks       exon    218671  219224  .       +       .       gene_id "XLOC_000007"; transcript_id "TCONS_00000005"; exon_number "1"; gene_name "slc43a1b"; oId "CUFF.50.1"; nearest_ref "ENSORLT00000000013"; class_code "s"; tss_id "TSS7";
  </code></pre>
  
  <p>Disired output:</p>
  
  <pre><code>    1       Cufflinks       exon    162752  163607  .       +       .       gene_id "XLOC_000001"; transcript_id "TCONS_00000001"; exon_number "1"; oId "CUFF.1.1"; class_code "u"; tss_id "TSS1";
      1       Cufflinks       exon    177199  177399  .       +       .       gene_id "XLOC_000002"; transcript_id "TCONS_00000002"; exon_number "1"; oId "CUFF.3.1"; class_code "u"; tss_id "TSS2";
      1       Cufflinks       exon    180630  180720  .       +       .       gene_id "XLOC_000003"; transcript_id "ENSORLT00000000006"; exon_number "5"; gene_name "ENSORLG00000000007"; oId "CUFF.15.1"; nearest_ref "ENSORLT00000000006"; class_code "s"; tss_id "TSS3";
      1       Cufflinks       exon    218671  219224  .       +       .       gene_id "XLOC_000007"; transcript_id "ENSORLT00000000013"; exon_number "1"; gene_name "slc43a1b"; oId "CUFF.50.1"; nearest_ref "ENSORLT00000000013"; class_code "s"; tss_id "TSS7";
  </code></pre>
  
  <p>Explanation:</p>
  
  <p>If there is a field <code>nearest_ref</code>, write it in field <code>transcript_id</code>, else, do nothing.</p>
  
  <p>Field <code>nearest_ref</code>: </p>
  
  <pre><code>nearest_ref "XXXXXXX";
  </code></pre>
  
  <p>Field <code>transcript_id</code>:</p>
  
  <pre><code>transcript_id "XXXXXXX";
  </code></pre>
  
  <p>I would like a <code>awk</code> solution if possible.</p>
  
  <p>I don't know how to retrive fields based on their name and not on their position :</p>
  
  <pre><code>awk -v FS=" " 'length($20)&gt;20{$12=$20} 1' MyFile |less
  </code></pre>
  
  <p><em>Note : File is tab separated, 9th column is space separated.</em></p>
  
  <p><strong><em>Edit: Found a way to do it, but it is really bad, I am still interested in a better way to do it:</em></strong></p>
  
  <pre><code>awk -v FS=" " -v OFS="\t" 'length($20)&gt;20{$12=$20} 1' MyFile | sed "s/;\t/; /g" | sed 's/\t"/ "/g'
  </code></pre>