grep (bash) multi-line pattern

后端 未结 6 385
感情败类
感情败类 2021-01-15 01:14

In bash (4.3.46(1)) I have some multi-line so called fasta records where each record is initiated by on line with >name and the following lines DNA sequence ([AGCTNacgtn]),

6条回答
  •  抹茶落季
    2021-01-15 01:52

    With GNU grep:

    grep -Pzo '>chr2\n[AGCTNacgtn\n]+' file | grep .
    

    Output:

    >chr2
    TTGNACACCC
    TGGGGGAGTA
    

提交回复
热议问题