user8109
user8109

Reputation: 189

Recursively find ".sh" file and then execute my .sh file on that path

I have a folder which contains sub sub folders and some folders contains .sh file. I want to execute my .sh file in that path where I see a .sh file. I tried

find . -name '*.sh' 
./folder 1/folder 2/run.sh
./folder3/run.sh
./folder 4/run.sh
./folder5/run.sh

This find function is working correctly. Now I have another .sh file which I want to execute on .sh file path. I tried

find . -name '*.sh' /home/cool/Desktop/followup.sh {} ;

where followup.sh is my file. The command is getting executed at current directory . but it is not getting executed on run.sh file path.

I am new to bash scripting. What command or commands would I issue? Note that there are spaces in Folder name.

Upvotes: 2

Views: 2866

Answers (1)

Ashutosh Bharti
Ashutosh Bharti

Reputation: 367

find <parent-directory where all sub-folders with run.sh are located> -name '*.sh' -execdir /home/cool/Desktop/followup.sh {} \;

Upvotes: 1

Related Questions