Skip to content

Instantly share code, notes, and snippets.

@rpherrera
Last active August 31, 2023 01:26
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save rpherrera/d7a4d905775653b88e5f to your computer and use it in GitHub Desktop.
Save rpherrera/d7a4d905775653b88e5f to your computer and use it in GitHub Desktop.
get aws ecr repositories names with aws cli, parsing results with jq and stripping double quotes with sed or tr
#!/bin/bash
# stripping double quotes with sed
aws ecr describe-repositories | jq '.repositories[].repositoryName' | sed s/\"//g
# stripping double quotes with tr
aws ecr describe-repositories | jq '.repositories[].repositoryName' | tr -d '"'
@leonhoffman
Copy link

You can also use the jq "-r" to strip out the quotes.

aws ecr describe-repositories | jq -r '.repositories[].repositoryName'

@DanielCalvo
Copy link

DanielCalvo commented Dec 16, 2021

After some geeking around, turns out you can use --query to get this exact output as well:

aws ecr describe-repositories --query "repositories[].[repositoryName]" --output text --no-cli-pager

Using aws-cli/2.2.38 Python/3.8.8

@vesubramanian
Copy link

Awesome @DanielCalvo. Thank you very much.

@ramirez368
Copy link

and sorry if you want to filter even more, let's say specific image_tag on that repo, you'll add another jq paramenter?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment