This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to add line breaks before each ">" header line in fasta file

Hello, I have a big fasta file with hundreds of sequences. In some cases the fasta sequences do not have line breaks between them. I would like to add a line break before each header.

For example, right now it looks like this:

">name ATCGCTGCGAT>name2 ATATCGTGA"

And I want it to look like this:

">name ATCGCTGCGAT"

">name2 ATATCGTGA"

Thank you for any help!

bash fasta

1 answer

sed 's/>/\n&/g' file

This worked perfectly! Thanks

Log in to answer this question.