title: Shell script reverse two concatenated variables?
body: <p>I just wanted to concatenate two string variables, but the output is somehow reversed. Would anyone please let me know why? Thanks!!</p>
  
  <p>My shell script:</p>
  
  <pre><code>HEADER=`cat header-cp-match-src-file.csv`
  echo header: $HEADER
  HEADER="$HEADER,Hello,123456"
  echo header: $HEADER
  </code></pre>
  
  <p>The output:</p>
  
  <pre><code>header: good_description,tranx count
  ,Hello,123456description,tranx count
  </code></pre>
  
  <p>The first line is correct, but the final output doesn't have the <code>"header:"</code> and the <code>",Hello,123456"</code> goes to the front of the string.</p>
  
  <p>========== SOLUTION ==========</p>
  
  <p>The file <code>header-cp-match-src-file.csv</code> is originally from Windows env, so it contains a <code>\r</code>, based on the suggestion, it works fine now after removing the <code>\r</code>. Thanks!!</p>
  
  <pre><code>HEADER=`cat header-cp-match-src-file.csv`
  echo header: $HEADER
  HEADER=${HEADER/$'\r'/}
  HEADER="$HEADER,KEVIN,123456"
  echo header: $HEADER
  </code></pre>