Gcloud命令行获取默认的project_id [英] Gcloud command line get default project_id

查看:144
本文介绍了Gcloud命令行获取默认的project_id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种衬垫以获取默认项目ID

I'm looking for a one-liner to get the default project id

gcloud config list core/project 给我

Your active configuration is: [default]
[core]
project = myproject_id

虽然我只想拥有myproject_id.目的是在脚本中使用结果.

While I want to have only myproject_id. The goal is to use the result in a script.

推荐答案

最简单的方法是在gcloud上使用--format标志.

The easiest way to do this is to use the --format flag on gcloud.

gcloud config list --format 'value(core.project)' 2>/dev/null

--format标志在所有命令上均可用,可让您完全控制打印的内容和格式.

The --format flag is available on all commands and gives you full control over what is printed, and how it is formatted.

您可以查看此帮助页面以获取完整信息:gcloud topic formats

You can see this help page for full info: gcloud topic formats

这篇关于Gcloud命令行获取默认的project_id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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