vendredi 3 avril 2015

shell script : for loop on list of files

I have a folder with lots of files and I want to perform an action with some of the files. I have files "BlaBla_01.mat", "BlaBla_02.mat" up to "BlaBla_11.mat"



{ time mpiexec -n 40 ./runex @alg.param BlaBla_01.mat; }


--> this generates 2 output files. I need to rename and move them...



mv FirstOut.log My/Folder/Results/FirstOut_BlaBla_01.log
mv NextOut.log My/Folder/Results/NextOut_BlaBla_01.log


How do I make this in a for loop so that the files are processed and renamed as they should?


I have tried:



NUMS='01 02 03 04 05 06 07 08 09 10 11'
for i in $NUMS;
do
FILENAME="BlaBla_"$i".mat"
{ time mpiexec -n 40 ./runex @alg.param $FILENAME; }
mv FirstOut.log "My/Folder/Results/FirstOut_BlaBla_"$i".log"
mv NextOut.log "My/Folder/Results/NextOut_BlaBla_"$i".log"
done;


and many variants of it, but it does not work.


I am sorry this must be a very easy question but I am not a programmer so this is my first week on shell scripts


Thank you in advance,


have a nice weekend


Seb


Aucun commentaire:

Enregistrer un commentaire