Andrés Parada Andrés Parada - 2 months ago 13
Perl Question

for loop calling two different files (same name, different extension) across several files

I have several files. I need to run a perl script calling all the files in a folder, simultaneously calling one file with extension .pep and another that is a similar file and matches the same name but different extension, .pep.nuc (like

Oh01.pep
and
Oh001.pep.nuc
)

I have this script so far, but I am missing something of course.

for file *.pep; do ./script.pl *.pep *.pep.nuc > "${file%.*}.nucleo"; done

Answer

This should do it:

for file in *.pep; do
    ./script.pl  "$file" "${file}.nuc" > "${file%.pep}.nucleo";
done