如何使用gcloud命令从json中仅提取名称字段? [英] How can I extract only the name field from json by using gcloud command?

查看:56
本文介绍了如何使用gcloud命令从json中仅提取名称字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是gcp和linux的新手.我正在尝试使用 gcloud 命令从 json 格式获取名称.下面是命令和输出:

I am new to gcp and linux. I am trying to get the name from the json format using the gcloud command. Below is the command and output:

gcloud firestore indexes composite list --format=json

输出:

[
  {
    "fields": [
      {
        "fieldPath": "is_active",
        "order": "ASCENDING"
      },
      {
        "fieldPath": "created_at",
        "order": "DESCENDING"
      },
      {
        "fieldPath": "__name__",
        "order": "ASCENDING"
      }
    ],
    "name": "projects/emc-ema-simcs-d-286404/databases/(default)/collectionGroups/customer/indexes/CICAgNjbhowK",
    "queryScope": "COLLECTION",
    "state": "READY"
  }

如何使用gcloud命令获取 name 值.我尝试使用: gcloud firestore索引复合列表|grep名称|awk -F'name:''{print $ 2}',但这没有任何输出.

How can I get the name value using gcloud command. I tried using: gcloud firestore indexes composite list | grep name | awk -F'name: ' '{print $2}' but this didn't give any output.

请帮助!

谢谢英式

推荐答案

最后,我能够使用以下命令获取 name 值:

Finally, I was able to get the name value using the below command:

gcloud firestore索引组合列表--format = json |grep'"名称"'|awk -F'''{print $ 2}'|awk -F''''{print $ 2}'

输出:

projects/emc-ema-simcs-d-xxxxxx/databases/(default)/collectionGroups/customer/indexes/CICAgNjbhowK

这篇关于如何使用gcloud命令从json中仅提取名称字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆