Pritish
Pritish

Reputation: 774

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.

Upvotes: 2

Views: 5573

Answers (2)

DazWilkin
DazWilkin

Reputation: 40061

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.

Upvotes: 7

Pritish
Pritish

Reputation: 774

To get the project name of your GCP project, use the below command:

gcloud projects describe $PROJECT_ID | grep name | awk -F'name: ' '{print $2}'

where, $PROJECT_ID is the id of your GCP project

Upvotes: 1

Related Questions