title: BASH - How to get variable from the script that runs in the background
body: <p>I have 2 bash files, file a.sh and file b.sh.</p>
  
  <p>contents of the file a.sh</p>
  
  <pre><code># !/bin/bash
  (/root/b.sh) &amp; # &lt;--- must be run in the background!!!
  sleep 1
  echo "--${VAR}--"
  </code></pre>
  
  <p>contents of the file b.sh</p>
  
  <pre><code># !/bin/bash
  VAR=100
  </code></pre>
  
  <p>run script /root/a.sh and the result is: ----</p>
  
  <p><strong>why is not the result: --100--</strong> ?</p>