Cbq command to store data for each iteration inside a loop

Hi All,

I wanted to loop some ids and export the data using cbq command in a file. However while doing this, previous data is getting overwritten by new data. I wanted to store data for each time until loop is finished.

I am using below query as of now. Can you please suggest me something to achieve it.

for price in "${priceIds[@]}"
do
  
  price=$(echo "$price" | sed 's/^[ \n]*//;s/[ \n]*$//')
  
  cbq -u Administrator -p ${password} -q -e "http://localhost:8093"  --script="select * FROM \`com.src.test\` where docId==\"${price}\";" | jq -c '.results[0]."com.src.test"' >output.json

done

Did you try with append mode of shell i.e. double grater than

>> output.json

It worked. Silly mistake from my side. :slight_smile: