skip to Main Content

Im trying to list the image tags from ECR repo using below command on windows

aws ecr list-images --repository-name plat   | jq '.imageIds   | map (.imageTag)  | sort | .[]'   | sort -r   | head -1

I installed jq utility , however , it says 'map' is not recognized as an internal or external command,

i tried lot finding map utility for windows but did not get . how can I make this entire command work on windows ? it worked perfectly on linux.

any workaround ?
do we have any equivalent command on windows ? please suggest

UPDATE 1

on windows

C:UsersikDownloads>aws ecr list-images --repository-name plat   | jq '.imageIds   | map (.imageTag)  | sort | .[]'   | sort -r   | head -1
'map' is not recognized as an internal or external command,
operable program or batch file.
PS C:UsersikDownloads>

on linux

root@CSX-Ik:~# aws ecr list-images --repository-name plat | jq '.imageIds | map (.imageTag)|sort|.[]' | sort -r | head -1
"19617.1"
root@CSX-Ik:~#

UPDATE 2

PS C:UsersikDownloads> aws ecr list-images --repository-name plat
{
    "imageIds": [
        {
            "imageDigest": "sha256:5fd06c0b6c6349324343232432429e8bf6b1ce62d810c2eef1eca",
            "imageTag": "20230421.001"
        },
        {
            "imageDigest": "sha256:d7a28e9e62c5465465465469080eeae6a8308c99ec032a845119202f6d427ef8",
            "imageTag": "33345.1"
        },
        {
            "imageDigest": "sha256:681ae17a52a4c673cc8c62d50823432432432432432432497789879c37a4",
            "imageTag": "3445.2"
        },
        {
            "imageDigest": "sha256:ff7090d214ac72334323243209809809803e8af",
            "imageTag": "33456.1"
        }
}
]
}

after putting map equivalent

C:UsersikDownloads>aws ecr list-images --repository-name plat   | jq '.imageIds   | [.[]   | .imageTag]   | sort | .[]'   | sort -r   | head -1
'[.[]' is not recognized as an internal or external command,
operable program or batch file.
PS C:UsersikDownloads> 

2

Answers


  1. Chosen as BEST ANSWER

    here is the command on windows

    For Windows :

    powershell.exe aws ecr list-images --repository-name <repo-name> | jq '.imageIds | map (.imageTag) | sort | reverse | first'"
    

    same is mentioned here

    https://eduwebmonster.com/how-to-list-aws-ecr-images-with-latest-tag-on-windows-and-linux/


  2. Use the built in --query parameter of AWS cli. So this is what you need:

    aws ecr list-images --repository-name plat --query 'imageIds[].imageTag' --output text
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search