title: Printing a sequence from a fasta file
body: <p>I often need to find a particular sequence in a fasta file and print it. For those who don't know, fasta is a text file format for biological sequences (DNA, proteins, etc.). It's pretty simple, you have a line with the sequence name preceded by a '>' and then all the lines following until the next '>' are the sequence itself. For example:</p>
  
  <pre><code>&gt;sequence1
  ACTGACTGACTGACTG
  &gt;sequence2
  ACTGACTGACTGACTG
  ACTGACTGACTGACTG
  &gt;sequence3
  ACTGACTGACTGACTG
  </code></pre>
  
  <p>The way I'm currently getting the sequence I need is to use grep with -A, so I'll do</p>
  
  <pre><code>grep -A 10 sequence_name filename.fa
  </code></pre>
  
  <p>and then if I don't see the start of the next sequence in the file, I'll change the 10 to 20 and repeat until I'm sure I'm getting the whole sequence.</p>
  
  <p>It seems like there should be a better way to do this. For example, can I ask it to print up until the next '>' character?</p>