I have a
MainDirectory/hundreds_of_subdirectories/thousands_of_fastas structure. For each fasta (a bioinformatics file format) in the bottom level, I am trying to change the file name as well as the first line in the file to retain only some parts of the file.
So that the following text, which makes up both the file name and the first name of the file:
For editing the first line in the file, I have tried
sed '1 s/^[^|uce-]*(|uce-[0-9]).*/\1/' hundreds_of_subdirectories/*
but this isn't the ticket..
Then messing around with some kind of loop...
for i in *\*.unaligned.fasta; do sed -E 's/^[^|uce-]*(|uce-[0-9]).*/\1/'; done
For the file name, it was suggested that I use
rename instead of
sed, but with
sed I have tried something like:
for x in hundreds_of_subdirectories/thousands_of_fastas*unaligned.fasta; do echo $x | sed -r 's/^[^|uce-]*(|uce-[0-9]).*/mv' -v "\0" "|uce-[0-9].*/\1/.unaligned.fasta"/ done
Am I even barking up the right tree? Thanks!