I have a bash function like below.
function createJson
{
START=1
END=100
jq -n 'reduce range($START; $END) as $data (.; . + [{"field": { "empID": $data, "location": "India"}}])' > test.json
}
The above script works fine If I mention the direct numeric value in "reduce range". For Example:
jq -n 'reduce range(0; 100) as $data (.; . + [{"field": { "empID": $data, "location": "India"}}])' > test.json
But when I tried to pass the shell variable to jq -n reduce range it throws error like below.
jq: error: START/0 is not defined at <top-level>, line 1:
reduce range($START; $END) as $data (.; . + [{"field": { "empID": $data, "location": "India"}}])
jq: error: END/0 is not defined at <top-level>, line 1:
reduce range($START; $END) as $data (.; . + [{"field": { "empID": $data, "location": "India"}}])
jq: 2 compile errors