title: How to parse HTTP headers using Bash?
body: <p>I need to get 2 values from a web page header that I am getting using curl.  I have been able to get the values individually using:</p>
  
  <pre><code>response1=$(curl -I -s http://www.example.com | grep HTTP/1.1 | awk {'print $2'})
  response2=$(curl -I -s http://www.example.com | grep Server: | awk {'print $2'})
  </code></pre>
  
  <p>But I cannot figure out how to grep the values separately using a single curl request like:</p>
  
  <pre><code>response=$(curl -I -s http://www.example.com)
  http_status=$response | grep HTTP/1.1 | awk {'print $2'}
  server=$response | grep Server: | awk {'print $2'}
  </code></pre>
  
  <p>Every attempt either leads to a error message or empty values.  I am sure it is just a syntax issue.</p>