title: Keep only the first and the centre part of a string between "_"
body: <p>I have a file with hundreds of lines like:</p>
  
  <pre><code>&gt;hg38_ct_tbrefGene_6787_NM_006820_utr3_8_0_chr1_78641810_f
  </code></pre>
  
  <p>For only those lines that have the ">" symbol I want to extract the ">" and the "NM_...". In the example above I want to get:</p>
  
  <pre><code>&gt;NM_006820
  </code></pre>
  
  <p>I'm not sure if this is important but there is also the possibility that some lines share the output (">NM_006820") more than once. </p>
  
  <p>Tried with <code>gsub()</code> but got completely lost.</p>