0
点赞
收藏
分享

微信扫一扫

linux之jq命令

非衣所思 2023-09-21 阅读 37
linux运维

jq命令用于linux命令行对json进行处理

参数

option

-r:去掉字符串的引号'"'

例子

tt.json文件如下:

[
    {
        "metric": "httpcode",
        "tags": {
            "cluster": "tt",
            "domain": "www.baidu.com"
        }
    },
    {
        "metric": "httpcode",
        "tags": {
            "cluster": "tt",
            "domain": "www.pingan.com"
        }
    },
    {
        "metric": "httpcode",
        "tags": {
            "cluster": "tt",
            "domain": "www.dy.com"
        }
    }
]
# jq命令后面一定不能忘了加引号
lxm@mypc  ~/Documents/image  cat tt.json| jq -r '.[].tags.domain'
www.baidu.com
www.pingan.com
www.dy.com

参考
https://blog.csdn.net/wzj_110/article/details/117387891

举报

相关推荐

0 条评论