passing arguments to jq filter

前端 未结 4 1909
孤城傲影
孤城傲影 2020-11-29 07:33

Here is my config.json:

{
    \"env\": \"dev\",
    \"dev\": {
        \"projects\" : {
            \"prj1\": {
                \"dependencies\": {},
                


        
4条回答
  •  醉话见心
    2020-11-29 07:54

    The jq program .dev.projects."$v" in your example will literally try to find a key named "$v". Try the following instead:

    jq --arg v "$PRJNAME" '.dev.projects[$v]' config.json 
    

提交回复
热议问题