title: Extract values from command output to a JSON
body: <p>I am extracting values from a cloud foundry command. It has to be done via the shell. Here is how the file looks like:</p>
  
  <pre><code>User-Provided:
  end: 123.12.12.12
  text_pass: 980
  KEY: 000
  
  Running Environment Variable Groups:
  BLUEMIX_REGION: ibm:yp:us-north
  
  Staging Environment Variable Groups:
  BLUEMIX_REGION: ibm:yp:us-south
  </code></pre>
  
  <p>I want to extract everything from end to KEY and please note that user-provided will always be the start but the end can be any value. But there will always be a new line.</p>
  
  <p>How do I extract between "User-Provided to new line" and put in a JSON file which I will later use to parse?</p>
  
  <p>So far I'm able to do this:</p>
  
  <blockquote>
    <p><code>cf env space | awk -F 'end:' '{print $2}'</code></p>
  </blockquote>
  
  <p>this gives me the value of end but not the whole object.</p>
  
  <p>Expected output:</p>
  
  <pre><code>{
  "end": "123.12.12.12"
  "text_pass": "980"
  "KEY": "000"
  }
  </code></pre>