title: Bash variable curl grep awk, echo order wrong
body: <p>I'm trying to parse the result of a CURL request. More specific, the &quot;Location&quot; header.
  Note: I'm trying to execute one HTTP request with CURL and use the following for processing: command exit code, stderr output (HTTP status code &amp; HTTP headers) and stdout output (HTTP body, in this case: HTML).</p>
  <p>I'm having some strange issues with string comparisons on the output and therefore I've started echo-ing the output and started to see some inexplicable things.</p>
  <p><strong>Bash script (./google_header_location.sh)</strong></p>
  <pre><code>#!/bin/bash
  HTTP_HEADER_LOCATION=$(curl -I google.com 2&gt;/dev/null | grep Location |  awk '{print $2}')
  echo &quot;HTTP header location: START ${HTTP_HEADER_LOCATION} END&quot;
  </code></pre>
  <p><strong>Command to execute the script above</strong></p>
  <pre><code>root@1274eaa3c485:/# ./google_header_location.sh 
  </code></pre>
  <p><strong>Response</strong></p>
  <pre><code>END header location: START http://www.google.com/
  </code></pre>
  <p>I've ran the script above on: <a href="https://hub.docker.com/layers/ubuntu/library/ubuntu/20.04/images/sha256-9d42d0e3e57bc067d10a75ee33bdd1a5298e95e5fc3c5d1fce98b455cb879249?context=explore" rel="nofollow noreferrer">https://hub.docker.com/layers/ubuntu/library/ubuntu/20.04/images/sha256-9d42d0e3e57bc067d10a75ee33bdd1a5298e95e5fc3c5d1fce98b455cb879249?context=explore</a>. More generic: ubuntu:20.04 on hub.docker.com</p>
  <p>I expected to see:
  echo &quot;HTTP header location: START <a href="http://www.google.com" rel="nofollow noreferrer">http://www.google.com</a> END&quot;</p>
  <p>I don't understand why &quot;END&quot; is echo'd first. What am I doing wrong?</p>