Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step 9 - cleanup - awk commands refer to wrong field ($) #63

Open
christoforos86 opened this issue May 25, 2023 · 1 comment
Open

Step 9 - cleanup - awk commands refer to wrong field ($) #63

christoforos86 opened this issue May 25, 2023 · 1 comment

Comments

@christoforos86
Copy link

Hello and thanks for the the tutorial on "Deploy a website with Cloud Run".
I believe that step 9 for cleaning up has an issue in the section for "Delete Cloud Build artifacts from Cloud Storage":
The command for printing all available soures is:
gcloud builds list | awk 'NR > 1 {print $4}'
This returns blank lines.
image

If I run "gcloud builds list", the results with the available source archives only have data in two fields, one with the description of the fields ($1) and one with the information ($2).
image
When running for field 1, I get the following:
image
When running for field 2, I get the following:
image

I believe that the $4 in the example is wrong as there is no 4th field to populate data from as the fields seem to be read in columns.
That explains why when running with $4, I get blank lines, since there is no 4 field when the data are read columnwise.

I assume the intention was to read rows of IDs, and except for the first one (which is the last one created), pull the 4th field (SOURCE) for other entries and remove them.

However for that to happen, I assume some additional command is required to read the fields in rows for each entry?

@christoforos86
Copy link
Author

christoforos86 commented May 25, 2023

I believe that the correct syntax should be:
gcloud builds list | awk '/^SOURCE:/ {print $2}' but this prints all sources.
It somehow needs to be combined with NR>1 to exclude the top entry but
gcloud builds list | awk 'NR > 1 && /^SOURCE:/ {print $2}'
does not seem to be reading the first entry, just the 1st row (ID).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant