I have fasta file namely `119XCA.fasta` as shown below,

    >cellulase
    ATGCTA
    >gyrase
    TGATGCT
    >16s
    TAGTATG
I need to remove all the fasta headers, keep the sequences one by one and need to write file name as a fasta header. The expected outcome is shown below,

    >119XCA
    ATGCTA
    TGATGCT
    TAGTATG
I have used the following script `sed '/^>/d' foo.fa > out.fa` which remove the fasta headers but, i do not know how to manage to write file name as a header. Therefore, please help me to do the same.


   

Assuming you're using BASH, use `basename` to get the filename with no PATH. Like:

    filename=$(basename -i file | cut -d'.' -f1)

Then you could replace it using sed 

    sed -i "s/^\>.*$/$filename/" your.fasta

Remember to use double quotes to use variables in sed.