Skip to main content
edited destired output
Source Link
jesse
  • 13
  • 3

I would like to take each line of the output of one gcloud command for use in another gcloud command.

gcloud container clusters list |grep jesse (alias gccl) output:

jesse-gke1                us-eastx-x
jesse-gke2                us-eastx-x

I need both of these variables (name and region) in the next command.

But when I try to use awk to get the variables I need for the next command, it combines both results into a single variable with 2 lines.

cluster=$(gccl 2>/dev/null|grep jesse|awk '{print $1}') ; echo $cluster

Outputs:

jesse-gke1
jesse-gke2

How can I get both of the output items in a command that would look like:

gcloud someaction $1jesse-gke1 $2zone=us-eastx-x

and iterate through the results?

Thanks!

I would like to take each line of the output of one gcloud command for use in another gcloud command.

gcloud container clusters list |grep jesse (alias gccl) output:

jesse-gke1                us-eastx-x
jesse-gke2                us-eastx-x

I need both of these variables (name and region) in the next command.

But when I try to use awk to get the variables I need for the next command, it combines both results into a single variable with 2 lines.

cluster=$(gccl 2>/dev/null|grep jesse|awk '{print $1}') ; echo $cluster

Outputs:

jesse-gke1
jesse-gke2

How can I get both of the output items in a command that would look like:

gcloud someaction $1 $2

?

Thanks!

I would like to take each line of the output of one gcloud command for use in another gcloud command.

gcloud container clusters list |grep jesse (alias gccl) output:

jesse-gke1                us-eastx-x
jesse-gke2                us-eastx-x

I need both of these variables (name and region) in the next command.

But when I try to use awk to get the variables I need for the next command, it combines both results into a single variable with 2 lines.

cluster=$(gccl 2>/dev/null|grep jesse|awk '{print $1}') ; echo $cluster

Outputs:

jesse-gke1
jesse-gke2

How can I get both of the output items in a command that would look like:

gcloud someaction jesse-gke1 zone=us-eastx-x

and iterate through the results?

Thanks!

Source Link
jesse
  • 13
  • 3

parse command output for use in next command

I would like to take each line of the output of one gcloud command for use in another gcloud command.

gcloud container clusters list |grep jesse (alias gccl) output:

jesse-gke1                us-eastx-x
jesse-gke2                us-eastx-x

I need both of these variables (name and region) in the next command.

But when I try to use awk to get the variables I need for the next command, it combines both results into a single variable with 2 lines.

cluster=$(gccl 2>/dev/null|grep jesse|awk '{print $1}') ; echo $cluster

Outputs:

jesse-gke1
jesse-gke2

How can I get both of the output items in a command that would look like:

gcloud someaction $1 $2

?

Thanks!