title: split a fasta file and rename on the basis of first line
body: <p>I have a huge file with following content:</p>
  
  <p>filename: input.txt</p>
  
  <pre><code>&gt;chr1
  jdlfnhl
  dh,ndh
  dnh.
  
  dhjl
  
  &gt;chr2
  dhfl
  dhl
  dh;l
  
  &gt;chr3
  
  shgl
  sgl
  
  &gt;chr2_random
  dgld
  </code></pre>
  
  <p>I need to split this file in such a way that I get four separate file as below:</p>
  
  <p>file 1: chr1.fa </p>
  
  <pre><code>&gt;chr1
  jdlfnhl
  dh,ndh
  dnh.
  
  dhjl
  </code></pre>
  
  <p>file 2: chr2.fa</p>
  
  <pre><code>&gt;chr2
  dhfl
  dhl
  dh;l
  </code></pre>
  
  <p>file 3: chr3.fa</p>
  
  <pre><code>&gt;chr3
  
  shgl
  sgl
  </code></pre>
  
  <p>file 4: chr2_random.fa</p>
  
  <pre><code>&gt;chr2_random
  dgld
  </code></pre>
  
  <p>I tried csplit in linux, but could not rename them by the text immediately after  ">". </p>
  
  <pre><code>csplit -z input.txt '/&gt;/' '{*}'
  </code></pre>