0

here is my bash script test.sh

host='select((.tag_name!="dev")
curl -H "Authorization: token <token>" https:<git release url> | jq -r  '[.[] | <iwant host variable placed here> ][0].assets[0].browser_download_url' 

I want to do something like below

curl -H "Authorization: token <token>" https:<git release url>  | jq -r '[.[] | select(.tag_name=="dev" )][0].assets[0].browser_download_url'
Pratheek Reddy
  • 103
  • 1
  • 8
  • 2
    does this help? https://stackoverflow.com/questions/13799789/expansion-of-variables-inside-single-quotes-in-a-command-in-bash e.g. `... | jq -r '[.[] | '"$host"' ][0].assets[0].browser_download_url'` – MarcoLucidi May 03 '22 at 19:57

2 Answers2

0

Try this: $(host)

host='select(.tag_name=="dev")'
curl -H "Authorization: token <token>" https:<git release url> | jq -r  '[.[] | $(host) ][0].assets[0].browser_download_url'
Marcelo Guedes
  • 1,419
  • 11
  • 10
0
... | jq -r  '[.[] | '"$host"' ][0].assets[0].browser_download_url' 
Pratheek Reddy
  • 103
  • 1
  • 8