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.


   

Not the prettiest code in the world, but this will work.

Run it like so: `bash scriptname.sh /path/to/files/*.fasta`

    for file in $1 ; do
        cat $file | sed -e '1!{/^>.*/d;}' | \
                    sed ':a;N;$!ba;s/\n//2g' | \
                    sed '1!s/.\{80\}/&\n/g' | \
                    sed "s|>.*$|>${file##*/}|g" > $(basename "${file##*/}" ".fasta" ).fa
    done

You can also do it as a oneliner for a single file if needed:

    cat filename.fasta | sed -e '1!{/^>.*/d;}' | sed ':a;N;$!ba;s/\n//2g' | sed '1!s/.\{80\}/&\n/g' | sed "s|>.*$|>${file##*/}|g" > $(basename "${file##*/}" ".fasta" ).fa
