본문 바로가기

Linux

Run multiple shell scripts in different folders sequentially

반응형

(1) Let's say we have the folder structure like

 

Parent
      |--- Child0

      |--- Child1

 

and each Sub-folder (Child) has a shell script file 'Run_Child.sh'.

 

 

 

(2) Then, create a schell script file 'Run_Parent.sh' and write the following commands

 

for d in 0 1; 
do
  cd "Child$d" && sh Run_Child.sh; cd ../
done

 

Run_Parent.sh should be placed at Parent folder.

 

 

 

 

(3) Finally, run the script like

 

~/Parent$ sh Run_Parent.sh