Json jq匹配正则表达式

Json jq匹配正则表达式,json,jq,Json,Jq,假设我有一个文件,我运行cattesttab.json | jq'.action.service.spec.task | select(.container)|.container',它会给我 { "image": "ubuntu:latest", "args1": "tail", "args2": "-f", "args3": "/dev/null", "mounts": { "source": "/home/testVolume", "target": "

假设我有一个文件,我运行
cattesttab.json | jq'.action.service.spec.task | select(.container)|.container'
,它会给我

{
  "image": "ubuntu:latest",
  "args1": "tail",
  "args2": "-f",
  "args3": "/dev/null",
  "mounts": {
    "source": "/home/testVolume",
    "target": "/opt"
  },
  "dns_config": null
}

我应该如何编辑此命令获取所有args(args1、args2和args3)值(“tail”“-f”“/dev/null”)

用以下过滤器补充您的
jq
管道:

jq -r 'yourfilter | to_entries 
       | map(select(.key | test("^args[0-9]+")).value) | @tsv' testTab.json
输出:

tail    -f  /dev/null
不过,如果您已经发布了最初的
testTab.json
内容,我会帮助您优化当前的过滤器