Hello,
I have several hundred subdirectories which contain input files for a binary executable. I need to get into each of the subdirectories, run the executable and then move to the next one and repeat the process. What is the best way to do this?
Arbitrarily my file structures look like this
Parent_Dir/
Child1/My.exe In1.file In2.File In3.File
Child2/My.exe In1.file In2.File In3.File
Child3/My.exe In1.file In2.File In3.File
Child4/My.exe In1.file In2.File In3.File
...
Thank you for your help!
~Guss
What's your system?
find . -type d -mindepth 1 -maxdepth 1 | while read DIR
do
cd "$DIR" || continue
./my.exe
cd ..
done
I interpreted the requirements differently than Corona688. Corona688 assumed that you only have one level of subdirectory and that their is a different My.exe in each directory.
I assumed that there could be multiple levels of directory and that there is only one My.exe command and that it is on your search path ($PATH). If my assumptions are correct, you could try:
find "$(pwd)/Parent_Dir" -name In1.file | while IFS="" read -r path
do cd "${path%/*}"
My.exe In1.file In2.File In3.File
done
I find it strange that two of your three files in each directory has an F in In[23].File and one of your three files has an f in In1.file , but this script uses the names you supplied.