title: Extract token from a curl request and use in another shell command
body: <p>I've started picking up bash scripting and I'm stuck at something I'm trying to wrap my head around.</p>
  
  <p>I have a curl command that outputs a token and I need to use it in the following command:</p>
  
  <pre><code>curl -k 'https://server:port/session' -X POST -H 'Content-Type: application/json' -d '{"username":"admin","password":"password"}'
  </code></pre>
  
  <p>It then outputs a token here:</p>
  
  <pre><code>{"token":"ac07098ad59ca6f3fccea0e2a2f6cb080df55c9a52fc9d65"}
  </code></pre>
  
  <p>I then need to use it in the follow up command</p>
  
  <pre><code>curl https://server:port/ -k -X POST -H 'Content-Type: application/json' -H 'X-Cookie:token=token' -d '
  </code></pre>
  
  <p>I was thinking I could output the token to a file, then have a sed command write the token to a file, then the new command use a variable where token=$token</p>
  
  <p>Thanks!</p>