I'm looking for a one-liner to get the default project id
with gcloud config list core/project
give me
Your active configuration is: [default]
[core]
project = myproject_id
While I want to have only myproject_id. The goal is to use the result in a script.
The easiest way to do this is to use the --format
flag on gcloud.
gcloud config list --format 'value(core.project)' 2>/dev/null
The --format
flag is available on all commands and gives you full control over what is printed, and how it is formatted.
You can see this help page for full info: gcloud topic formats