How to not print a line if it and the following line starts with the same pattern?

I have a file.fa:

>ABC
TGTGTGT
AGAGAGA
TGTAGTA
>BDC
>DTR
>EDF
AGAGGTG
AGTGACA
CAGTGAC

I want to keep the lines without ">", and lines with ">" only if the immediate following line does not have ">":

>ABC
TGTGTGT
AGAGAGA
TGTAGTA
>EDF
AGAGGTG
AGTGACA
CAGTGAC

Looking at the answer for this post, I see that awk '/^>/{x=$0} !/^>/{if(x){print x;x=0;}}' file.fa prints out the header lines (with '>') that I want:

>ABC
>EDF

but how do I also get the lines of text without '>'?



from Recent Questions - Stack Overflow https://ift.tt/375xMwM
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation