title: Bash append to variable using while read syntax
body: <p>I have file which looks like following:</p>
  
  <pre><code>/usr/local/bin
  /bin
  /usr/bin
  /usr/local/sbin
  /usr/sbin
  /sbin
  /home/user/.local/bin
  /home/user/bin
  /home/user/perl5/bin
  </code></pre>
  
  <p>now I want to concatenate the lines by colon using while read syntax, something like this:</p>
  
  <pre><code>cat file | while read data; do path="$path:$data"; done &amp;&amp; echo $path
  </code></pre>
  
  <p>but above code is not working that I am expecting, the $path variable remains empty, what is the problem?</p>