title: read one line with "read" in bash, but without "while"
body: <p>I was trying to understand how "while read" works in bash, and i came accross a behaviour that i can't explain:</p>
  
  <pre><code>root@antec:/# var=old_value
  root@antec:/# echo "new_value" | read var &amp;&amp; echo $var
  old_value
  root@antec:/# 
  </code></pre>
  
  <p>It works fine with "while read":</p>
  
  <pre><code>root@antec:/# var=old_value
  root@antec:/# echo "new_value" | while read var; do echo $var; done
  new_value
  root@antec:/# 
  </code></pre>
  
  <p>Can someone explain why it does not work when read is used without while ? Moreover, i don't understand how the value of "var" in the main shell can be seen from the allegedly subshell after the pipe ..</p>
  
  <p>Thank you</p>