'concat a string variable in jq bash script
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'
Solution 1:[1]
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'
Solution 2:[2]
... | jq -r '[.[] | '"$host"' ][0].assets[0].browser_download_url'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Marcelo Guedes |
| Solution 2 | Pratheek Reddy |
