I am using jq to parse an array. The query works fine when I use in the following format and use a fixed value inside double quotes e.g. 123456.
jq -r '.[] | select(.principalName=="123456") | .principalName' sp.txt
However I am getting the value from a variable in a bash script and I want to pass the variable (e.g. $spName) into jq parameter instead of a hard coded value 123456 something like:
jq -r '.[] | select(.principalName=="$spName") | .principalName' sp.txt
When I do so, I am getting error. Obviously my syntax is not correct. Can someone help me to fix the syntax?