Stay organized with collections Save and categorize content based on your preferences.
gcloud
commands return a list of resources on success. By default they are pretty-printed on the standard output. The --format=
NAME
[ATTRIBUTES
](
PROJECTION
)
and --filter=
EXPRESSION
flags along with projections can be used to format and change the default output to a more meaningful result.
Use the --format
flag to change the default output format of a command. Resource formats are described in detail below.
Use the --filter
flag to select resources to be listed. For details run $ gcloud topic filters.
Use resource-keys to reach resource items through a unique path of names from the root. For details run $ gcloud topic resource-keys.
Use projections to list a subset of resource keys in a resource. For details run $ gcloud topic projections.
Note: To refer to a list of fields you can sort, filter, and format by for each resource, you can run a list command with the format set to text
or json
. For example, $ gcloud compute instances list --limit=1 --format=text.
To work through an interactive tutorial about using the filter and format flags instead, see: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/cloud-shell-tutorials&page=editor&tutorial=cloudsdk/tutorial.md
A format expression has 3 parts:
NAME
name
ATTRIBUTES
[
[no-]attribute-name
[=value
] [, … ] ]
PROJECTION
(
resource-key
[, …] )
NAME
is required, ATTRIBUTES
are optional, and PROJECTIONS
may be required for some formats. Unknown attribute names are silently ignored. Each gcloud
list
command has a default format expression. The --format
flag can alter or replace the default. For example,
--format="[box]"adds box decorations to a default table, and
--format=jsonlists the resource in
json
format. The formats and format specific attributes are:
config
The format attributes are:
export
unset
csv
To use \n
or \t
as an attribute value please escape the \
with your shell's escape sequence, example separator="\\n"
for bash.
The format attributes are:
delimiter="string"
no-heading
separator="string"
terminator="string"
default
yaml
format. To override use gcloud config set core/default_format
property.
diff
The format attributes are:
format
disable
none
format, but also short-circuits early for commands that return pageable lists.
flattened
key
:value
pair.
The format attributes are:
no-pad
no-pad
for comparing resource outputs.
separator=SEPARATOR
SEPARATOR
between the key
and value
. The default is ": ".
get
value[no-transforms]
format. Default transforms are not applied to the displayed values.
json
The format attributes are:
no-undefined
list
The format attributes are:
always-display-title
compact
multi
`--format="multi(data:format=json, info:format='table[box](a, b, c)')"`
formats the data
field as JSON and the info
field as a boxed table.
The format attributes are:
separator
none
object
The format attributes are:
separator
terminator
table
If --page-size
=N
is specified then output is grouped into tables with at most N
rows. Headings, alignment and sorting are done per-page. The title, if any, is printed before the first table.
If screen reader option is True, you may observe flattened list output instead of a table with columns. Please refer to $ gcloud topic accessibility to turn it off.
The format attributes are:
all-box
box
format=FORMAT-STRING
FORMAT-STRING
which can reference any of the supported formats.
no-heading
margin=N
pad=N
N
spaces. The default is 1 for box, 2 otherwise.
title=TITLE
TITLE
at the top of the table, within the table box if box
is enabled.
text
flattened
format.
value
To use \n
or \t
as an attribute value please escape the \
with your shell's escape sequence, example separator="\\n"
for bash.
The format attributes are:
delimiter="string"
quote
separator="string"
terminator="string"
yaml
The format attributes are:
null="string"
null
for null/None values.
no-undefined
version=VERSION
All formats have these attributes:
disable
json-decode
private
transforms
no-transforms
to disable.
name
with box decorations and title Instances
:
gcloud compute instances list --format="table[box,title=Instances](name:sort=1, zone:label=zone, status)"
List a nested table of the quotas of a region:
gcloud compute regions describe us-central1 --format="table(quotas:format='table(metric,limit,usage)')"
Print a flattened list of global quotas in CSV format:
gcloud compute project-info describe --flatten="quotas[]" --format="csv(quotas.metric,quotas.limit,quotas.usage)"
List the disk interfaces for all compute instances as a compact comma separated list:
gcloud compute instances list --format="value(disks[].interface.list())"
List the URIs for all compute instances:
gcloud compute instances list --format="value(uri())"
List all compute instances with their creation timestamps displayed according to the local timezone:
gcloud compute instances list --format="table(name,creationTimestamp.date(tz=LOCAL))"
List the project authenticated user email address:
gcloud info --format="value(config.account)"
List resources filtered on repeated fields by projecting subfields on a repeated message:
gcloud alpha genomics readgroupsets list --format="default(readGroups[].name)"
Return the scope of the current instance:
gcloud compute zones list --format="value(selfLink.scope())"
selfLink is a fully qualified name. (e.g. 'https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a') The previous example returns a list of just the names of each zone (e.g. 'us-central1-a'). This is because selfLink.scope() grabs the last part of the URL segment. To extract selfLink starting from /projects and return the scope of the current instance:
gcloud compute zones list --format="value(selfLink.scope(projects))"
List all scopes enabled for a Compute Engine instance and flatten the multi-valued resource:
gcloud compute instances list --format="flattened(name,serviceAccounts[].email,serviceAccounts[].scopes[].basename())"
Display a multi-valued resource's service account keys with the corresponding service account, extracting just the first '/' delimited part with segment(0):
gcloud iam service-accounts keys list --iam-account=svc-2-123@test-minutia-123.iam.gserviceaccount.com--project=test-minutia-123 --format="table(name.scope(serviceAccounts).segment(0):label='service Account',name.scope(keys):label='keyID',validAfterTime)"
The last example returns a table with service account names without their full paths, keyID and validity.
gcloud alpha topic formats
gcloud beta topic formats
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-10-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-10-07 UTC."],[],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.5