Search code examples
shellcommand-linejqaws-cliaws-userpools

How to modify aws cli command output


I am using below command to list the UserPool Names.

aws cognito-idp list-user-pools --max-results 60 --region us-west-2 --query 'UserPools[*].{Names:Name}'

Now my all UserPool Names contains cust_ as prefix. And i want to remove that from whole list.

I know i can achieve this using jq. But how?

Any help will be highly appreciated.

Thanks!


Solution

  • If you output with --output text, it will become a text list.

    You could then use standard Linux tools such as piping it through | cut -c6-

    This will provide character #6 onwards for each line.

    Full command would be something like:

    aws cognito-idp list-user-pools --max-results 60 --region us-west-2 --query 'UserPools[*].[{Names:Name}]' --output text | cut -c6-