Home > Net >  concat a string variable in jq bash script
concat a string variable in jq bash script

Time:05-05

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'

CodePudding user response:

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'

CodePudding user response:

... | jq -r  '[.[] | '"$host"' ][0].assets[0].browser_download_url' 
  • Related