title: How to pass bash variable value in json file
body: <p>Add bash variables value to json file</p>
  
  <p>I am trying to get latest zip file from nexus using below curl command.</p>
  
  <p>Ouput of curl comes like this : 1.0.0.0-20190205.195251-396</p>
  
  <p>In the json field i need this value(1.0.0.0-20190205.195251-396) to be updated like this:  developer-service-1.0.0.0-20190205.195251-396.zip</p>
  
  <p>ERROR: [2019-02-06T16:19:17-08:00] WARN: remote_file[/var/chef/cache/developer-service-.zip] cannot be downloaded from <a href="https://nexus.gnc.net/nexus/content/repositories/CO-Snapshots/com/GNC/platform/developer/developer-service/1.0.9.9-SNAPSHOT/developer-service-.zip" rel="nofollow noreferrer">https://nexus.gnc.net/nexus/content/repositories/CO-Snapshots/com/GNC/platform/developer/developer-service/1.0.9.9-SNAPSHOT/developer-service-.zip</a>: 404 "Not Found"</p>
  
  <pre><code>#!/bin/bash
  latest=`curl -s http://nexus.gnc.net/nexus/content/repositories/CO-Snapshots/com/gnc/platform/developer/developer-service/1.0.9.9-SNAPSHOT/maven-metadata.xml | grep -i value | head -1 | cut -d "&gt;" -f 2 | cut -d "&lt;" -f 1`
  
  echo $latest
  
  sudo bash -c 'cat &lt;&lt; EOF &gt; /etc/chef/deploy_service.json
  {
    "portal" : {
      "nexus_snapshot_version":"developer-service-${latest}.zip"
      }
  }
  EOF'
  </code></pre>