Line feed is being removed from echo when called in double-quotes <p>I'm trying to populate a shell variable called <code>$recipient</code> which should contain a value followed by a new-line.</p> <pre><code>$ set -x # force bash to show commands as it executes them </code></pre> <p>I start by populating <code>$user</code>, which is the value that I want to be followed by the newline.</p> <pre><code>$ user=user@xxx.com + user=user@xxx.com </code></pre> <p>I then call <code>echo $user</code> inside a double-quoted command substitution. The <code>echo</code> statement should create a newline after <code>$user</code>, and the double-quotes should preserve the newline.</p> <pre><code>$ recipient="$(echo $user)" ++ echo user@xxx.com + recipient=user@xxx.com </code></pre> <p>However when I print <code>$recipient</code>, I can see that the newline has been discarded.</p> <pre><code>$ echo "'recipient'" + echo ''\''recipient'\''' 'recipient' </code></pre> <p>I've found the same behaviour under bash versions 4.1.5 and 3.1.17, and also replicated the issue under dash.</p> <p>I tried using "printf" rather than echo; this didn't change anything.</p> <p>Is this expected behaviour?</p>