Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

running shell script within shell script in a nested for loop

hi everyone I've got a simple script which executes another script in a nested for loop

my problem is that while the double for loop is executing fine without the addition of the script which needs to be run at each iteration, if i add the script the execution only happens once.

any ideas why?

for ((i = 0; i<10; i++))
do  
echo "outer forloop $i"
for ((j = 0; j<6; j++))
do
    exec ./run.sh
    done
done

thanks andreas

like image 393
kkudi Avatar asked Sep 18 '26 12:09

kkudi


1 Answers

exec replaces the current process with a new process. Use ./run.sh

like image 139
Erik Avatar answered Sep 22 '26 00:09

Erik