I'm attempting to parse the output of a script that takes a parameter and for each parameter pulls some json. I'm parsing with jq. On the command line for one run of the script a command like this one works:
./script_that_produces_json --intput=value | jq '.[] | select(.name=="objecName") | .fieldIWant
I need to run this for a variety of parameters, which I am attempting to read from an array. This is what my code looks like now:
for entry in "${array[@]}"
do
output=$(./script_that_produces_json --input=$entry | jq '.[] | select(.name=="$entry") | .fieldIWant)'
print($output)
done
This yields the variable substituted, but there are no quotes around it, which fails when passed to jq. I've been hacking around this with various combinations of quotes with no success.
How do I quote the variable/string correctly such that both the variable is replaced and the quotes are passed?