title: How to wait until everything started by a shell script ends?
body: <p>I am using nested shell scripts. </p>
  
  <p>My question is a bit similar to the ones asked <a href="https://stackoverflow.com/questions/22566304/shell-script-not-waiting">here</a> and <a href="https://stackoverflow.com/questions/6405039/shell-how-to-use-screen-and-wait-for-a-couple-of-background-processes-in-a-shel">here</a>. But not exactly the same. </p>
  
  <p>I have tried to get the solution from these but unsuccessful.</p>
  
  <p>In my <strong>OuterMostShellScript.sh</strong>, I do something like this:</p>
  
  <pre><code>some commands
  ./runThisScriptX.sh
  other commands
  end of script.
  </code></pre>
  
  <p><strong>runThisScriptX.sh</strong> contains a loop running some processes in the background by using <code>&amp;</code> operator.</p>
  
  <p>I want each process started by the <code>./runThisScriptX.sh</code> command finish before the control moves to the, which i say <code>other commands</code> line in the above code.</p>
  
  <p>how to achieve this?</p>
  
  <p>EDIT: I also did like this:</p>
  
  <pre><code>some commands
  ./runThisScriptX.sh
  wait
  other commands
  end of script.
  </code></pre>
  
  <p>but it did not work.</p>