我们有以下 json 文件
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"
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
我们只想打印内容的值
jq '.items[].properties | to_entries[] | " \(.value)"' t.json
" Licensed to the Apache Software Foundation"
" 20"
" 256"
" DEBUG"
" DEBUG"
" 20"
" 256"
Run Code Online (Sandbox Code Playgroud)
但它打印所有其他值
我错在哪里,我应该修复什么?
预期产出
" Licensed to the Apache Software Foundation"
Run Code Online (Sandbox Code Playgroud)
pLu*_*umo 20
尝试这个,
jq '.items[].properties.content' t.json
Run Code Online (Sandbox Code Playgroud)
添加-r,如果你想摆脱双引号
| 归档时间: |
|
| 查看次数: |
21248 次 |
| 最近记录: |