Quantcast
Viewing all articles
Browse latest Browse all 526

Passing bash variable to jq

I have written a script to retrieve certain value from file.json. It works if I provide the value to jq select, but the variable doesn't seem to work (or I don't know how to use it).

#!/bin/sh#this works ***projectID=$(cat file.json | jq -r '.resource[] | select(.username=="myemail@hotmail.com") | .id')echo "$projectID"EMAILID=myemail@hotmail.com#this does not work *** no value is printedprojectID=$(cat file.json | jq -r '.resource[] | select(.username=="$EMAILID") | .id')echo "$projectID"

Viewing all articles
Browse latest Browse all 526

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>