I am trying to run two scripts in the background. However I would like to have one script run first, wait for it to finish and run the next script recursively. Will this code snippet do as such:
for i in "${studyinstanceuids[@]}"
do
#let count="$count+1"
echo "$i" | ./cmd2&
sleep 5
if job1 is alive then sleep 5
echo "$i" | ./sendExamToRepo.sh&
wait
fi