9

we have the follwing json file

 more t.json
{
  "href" : "htr",
  "items" : [
    {
      "href" : "lpo",
      "tag" : "version1533203561827110",
      "type" : "kafka-log4j",
      "version" : 6,
      "Config" : {
        "cluster_name" : "hdp",
        "stack_id" : "HDP-2.6"
      },
      "properties" : {
        "content" : "Licensed to the Apache Software Foundation",
        "controller_log_maxbackupindex" : "20",
        "controller_log_maxfilesize" : "256",
        "ey=log4j.rootLogger" : "DEBUG",
        "ey=properties.content" : "DEBUG",
        "kafka_log_maxbackupindex" : "20",
        "kafka_log_maxfilesize" : "256"
      }
    }
  ]
}

we want to print only the value of content

jq '.items[].properties | to_entries[] |  " \(.value)"' t.json
" Licensed to the Apache Software Foundation"
" 20"
" 256"
" DEBUG"
" DEBUG"
" 20"
" 256"

but its print all the other values

where I am wrong , and what should I fix ?

expected output

" Licensed to the Apache Software Foundation"

1 Answer 1

24

Try this,

jq '.items[].properties.content' t.json

Add -r if you want to get rid of the double quotes

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.