This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Is there a way to split single .txt file with multiple fasta sequences into individual sequences in separate files

Hi there!

Can anyone help in answering how to split single .txt file with multiple fasta sequences into multiple files containing each of the fasta sequence?

Thank you for your time and help!

sequence

1 answer

using awk

awk '/^>/ {if(x>0) close(outname); x++; outname=sprintf("_%d.fa",x); print > outname;next;} {if(x>0) print >> outname;}' *.fasta

Thanks alot Pierre for the help....

Log in to answer this question.