Find and execute shell scripts in multiple sub directories in parallel

I have one parent directory and within that parent directory there are several other sub-directories and within those sub-directories there are several other "large number" of sub-directories.

All the sub directories have a shell script in them with a common file name execute_command.sh I want to execute all those shell scripts in parallel from within my parent directory.

I tried this but it does not work:

find . -type d -exec sh execute_command.sh {} \;

I am using Linux with BASH.

From the parent directory u can run

 
find . -name <script_name> | ksh
1 Like

It does not seem to work. Looks to me that this command can run as root user. Let me try out more options and if I succeed, I'll paste my code here. But my requirement is to run all the scripts in parallel rather than in batch mode.

$ find dir_path -type f -name "execute_command.sh" -exec sh {} \;
1 Like

To do it in parallel install GNU Parallel:

find . -type f -name "execute_command.sh" | parallel

Watch the intro video to learn more: Part 1: GNU Parallel script processing and execution - YouTube

1 Like