bash 找出 Google Cloud SDK 的安装位置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33920484/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Find out where Google Cloud SDK is installed
提问by Gabriel Petrovay
I need to add the Google Cloud SDK in the PATH
. So I need the path to where is installed. Is there any gcloud ...
command which gives me this information?
我需要在PATH
. 所以我需要安装位置的路径。有什么gcloud ...
命令可以给我这些信息吗?
If not I have to go through the symlink in which gcloud
, etc.
如果不是,我必须通过符号链接which gcloud
等。
Any cleaner solution for this problem?
这个问题有更清洁的解决方案吗?
回答by Zachary Newman
The following command will give you the information you're looking for:
以下命令将为您提供您正在寻找的信息:
$ gcloud info --format="value(installation.sdk_root)"
/path/to/google-cloud-sdk/
You need to append /bin
.
您需要附加/bin
.
You also have lots of other paths available: config.paths.global_config_dir
, installation.sdk_root
, and so on. Look at the output of gcloud info --format=json
for all available properties to query.
您还有许多其他可用路径:config.paths.global_config_dir
、installation.sdk_root
等等。查看gcloud info --format=json
要查询的所有可用属性的输出。
回答by EliuX
I used:
我用了:
dirname $(which gcloud)
And worked like a charm
像魅力一样工作