0

Do I have to run a jq command multiple times to get object values to bash variables?

{
    meta: {
        "type": "nestJS",
        "host": "domain.tld"
    }
}

Running jq -r .meta.type ./file.json gives me the output

{
    "type": "nestJS",
    "host": "domain.tld"
}

I would like to get a TYPE and a HOST variable in my bash script.

So do I have to run the command multiple times for each key?

TYPE=$(jq -r .meta.type ./file.json)
HOST=$(jq -r .meta.host ./file.json)
user3142695
  • 15,844
  • 47
  • 176
  • 332

0 Answers0