Can anyone help me with the following issue? I have circa 40 directories of different species, each with 100s of sequence files that contain orthologous sequences. The sequence files are similarly named for each of the species directories. I want to concatenate the identically named files of the 40 species directories into a single sequence file which is named similarly.
E.g. I have the following 3 directories: "Species1", "Species2", "Species3". Within these directories are similarly named files: "SequenceA.fasta", "SequenceB.fasta", "SequenceC.fasta". I need to concatenate all contents of the different SequenceA.fasta files into one new file named "SequenceA.fasta" in another directory. How do I do this?
I tried it with the following loop, which failed. Files are created but are empty:
ls . | while read FILE; do cat ./*/"$FILE" >> ./final/"$FILE"; done
Thanks for any advice or help!
(Sorry for any potential cross-posting, I accidentally posted this question in a wrong forum earlier)