Search code examples
bashawkgoogle-cloud-platformgcloud

How to get only the "project name" from GCP using gcloud command?


I am trying to get the project name of my GCP project. Firstly, I tried using the command:

gcloud projects describe $PROJECT_ID

Here you get the poject Id, number name, Organization and other details.

Then next use grep command to get the project Name.


Solution

  • It's often more convenient to use gcloud only:

    PROJECT=[[YOUR-PROJECT]]
    gcloud projects describe ${PROJECT} \
    --format="value(name)"
    

    You may use e.g. value(projectNumber) to get the project number.