I have a test.json file which contains below property.
"solr.baseuri":"http://10.201.17.8:80"
We are getting expected output for the below script if we parse the exact variable(solr.baseuri) name using jq command.
Shell script :
#!/bin/bash
key=`solr.baseuri`
value=`cat test.json |jq '."solr.baseuri"' | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b"`
echo "solr value is $value"
Output :
solr value is 10.201.17.8
not sure how to use the $key with jq command inside the script to display the value. trying with below command which is not working
value=`cat test.json |jq '."${key}"' | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b"`