title: Bash - Filtering lines according to a condition
body: <p>I have a file that contains some lines as:</p>
  
  <pre><code>@SRR4293695.199563512 199563512 
  CAAAANCATTCGTAGACGACCTGCTCTGTNGNTACCNTCAANAGATCNGAAGAGCACACGTCTGAACTCCAGTCAC
  +SRR4293695.199563512 199563512 
  A.AA&lt;#FF)FFFFFFF&lt;&lt;&lt;&lt;FF7FFFFFF#.#&lt;FF&lt;#FFFF#FF&lt;A&lt;#FFFFFFFAFFFFFFAAAFFFFF&lt;FFFF.
  @SRR4293695.199563513 199563513 
  CTAAANCATTCGTAGACGACCTGCTT
  +SRR4293695.199563513 199563513 
  &lt;AAAA#FFFFFF&lt;FFFFFFFFFFFFF
  @SRR4293695.199563514 199563514 
  CCAACNTCATAGAGGGACAAGTGGCGATCNGNC
  +SRR4293695.199563514 199563514 
  AAAAA#&lt;F.F&lt;&lt;FA.F7AA.)&lt;FAFA..7#.#A
  @SRR4293695.199563515 199563515 
  TCGCGNCCTCAGATCAGACGTGGCGA
  +SRR4293695.199563515 199563515 
  AAAAA#FFFFFF&lt;FFFFFFFFFFFFF
  @SRR4293695.199563516 199563516 
  TGACCNGGGTCCGGTGCGGAGAGCCCTTC
  +SRR4293695.199563516 199563516 
  AAAAA#FAFFFF&lt;F.FFAA.F)FFFFFAF
  @SRR4293695.199563517 199563517 
  AAATGNTCATCGACACTTCGAACGCACT
  +SRR4293695.199563517 199563517 
  AA)AA#F&lt;FFFFFFAFFFFF&lt;)FFFAFF
  @SRR4293695.199563518 199563518 
  TCGTANCCAATGAGGTCTATCCGAGGCGCN
  +SRR4293695.199563518 199563518 
  AAAAA#&lt;FAAFFFF.FFFFFFFA.FFFFF#
  @SRR4293695.199563519 199563519 
  AAAACNATTCGTAGACGNCCTGCTTNTGTNGNCACCNTNANNANNTCNGNAGAGCNCACNTCTGAACTCNAGTCAC
  +SRR4293695.199563519 199563519 
  AAAAA#FFFFFFFFFFF#FFFFFFF#FF&lt;#F#F.FF#7#F##F##A)#A#FF&lt;F)#AAF#&lt;FFFFAFF&lt;#&lt;FFFFF
  @SRR4293695.199563520 199563520 
  GAAGCNGCACAGCTGGCNTTGGAGCNGANNCNGTAGNCNCNNTNNATNGNTCGGNNGAGNACACGTCTGNACTCCA
  +SRR4293695.199563520 199563520 
  AAAAA#FFFFFFFFFFF#FFFFFFF#FF##A#FFFF#F#F##&lt;##FF#F#FFFF##FFF#FFFFFFFFF#FFFFFF
  @SRR4293695.199563521 199563521 
  TGGTCNGTGGGGAGTCGNCGCCTGCNTANNANTGTANGNANNANNAANANATCGNNAGANCACACGTCTNAACTCC
  +SRR4293695.199563521 199563521 
  AAAAA#FFFFFFFFFFF#FFFFFFF#FF##F#FFFF#F#F##A##FF#A#FFFF##&lt;FF#FFFFFFFFF#F&lt;FFFF
  @SRR4293695.199563522 199563522 
  TCGTANCCAATGAGGTCTATCCGAGGCGCN
  +SRR4293695.199563522 199563522
  AAAAA#&lt;FAAFFFF.FFFFFFFA.FFFFF#
  </code></pre>
  
  <p>Then, I would like to filter these lines according to a condition :
  taking in consideration the length of even lines: if that length is > 34 then that line and the preceding line must be removed.</p>
  
  <p>I already did an algorithm: using a while to read all lines in the file, checking the condition and retaining only lines with length &lt; 34. The problem is that it is taking some time. </p>
  
  <pre><code>inputFile=$1 
  outputFile=$2
  
  while read first_line; read second_line
    do
      lread=${#second_line}
      if [[ "$lread" -le 34 ]] ; then
          echo $first_line &gt;&gt; $outputFile
          echo $second_line &gt;&gt; $outputFile
      fi
  done &lt; $inputFile 
  
  # This is for the last two lines
  lread=${#second_line}
  if [[ "$lread" -le 34 ]] ; then
    echo $first_line &gt;&gt; $outputFile
    echo $second_line &gt;&gt; $outputFile
  fi
  </code></pre>
  
  <p>I was wondering if there is not another way, quicker.</p>
  
  <p>The expected output:</p>
  
  <pre><code>@SRR4293695.199563513 199563513 
  CTAAANCATTCGTAGACGACCTGCTT
  +SRR4293695.199563513 199563513 
  &lt;AAAA#FFFFFF&lt;FFFFFFFFFFFFF
  @SRR4293695.199563514 199563514 
  CCAACNTCATAGAGGGACAAGTGGCGATCNGNC
  +SRR4293695.199563514 199563514 
  AAAAA#&lt;F.F&lt;&lt;FA.F7AA.)&lt;FAFA..7#.#A
  @SRR4293695.199563515 199563515 
  TCGCGNCCTCAGATCAGACGTGGCGA
  +SRR4293695.199563515 199563515 
  AAAAA#FFFFFF&lt;FFFFFFFFFFFFF
  @SRR4293695.199563516 199563516 
  TGACCNGGGTCCGGTGCGGAGAGCCCTTC
  +SRR4293695.199563516 199563516 
  AAAAA#FAFFFF&lt;F.FFAA.F)FFFFFAF
  @SRR4293695.199563517 199563517 
  AAATGNTCATCGACACTTCGAACGCACT
  +SRR4293695.199563517 199563517 
  AA)AA#F&lt;FFFFFFAFFFFF&lt;)FFFAFF
  @SRR4293695.199563518 199563518 
  TCGTANCCAATGAGGTCTATCCGAGGCGCN
  +SRR4293695.199563518 199563518 
  AAAAA#&lt;FAAFFFF.FFFFFFFA.FFFFF#
  @SRR4293695.199563522 199563522 
  TCGTANCCAATGAGGTCTATCCGAGGCGCN
  +SRR4293695.199563522 199563522
  AAAAA#&lt;FAAFFFF.FFFFFFFA.FFFFF#
  </code></pre>
  
  <p>Thanks in advance!</p>