Celeb Glow
news | April 04, 2026

Edit FASTA header

I want to remove part of the header of all my sequences in a fasta file, so only the Otu number appears as the header.

So from:

>M02300_51_000000000-CJMTC_1_1115_17014_15334 Otu0001
T-AC--GG-AG-GGT---GCA-A-G-C--G-T-T--AA-T-CGG-AA--TT-A-C-T

I would like to change it to:

>Otu0001
T-AC--GG-AG-GGT---GCA-A-G-C--G-T-T--AA-T-CGG-AA--TT-A-C-T

I believe this should be possible with the sed command but haven't been able to make it work. Any help would be great! Thank you in advance.

1 Answer

I don't know anything about the structure of FASTA, but if the substring Otu cannot appear anywhere else in the header, then

sed 's/^>.*Otu/>Otu/' file.fasta

should do it

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy