Search code examples
amazon-s3aws-cli

AWS S3 - Example of searching files in S3 using regex


How to list the files in S3 using regex (in linux cli mode)? I have the files in s3 bucket like sales1.txt, sales2.txt etc. When I ran the below command nothing is displaying. Is there a command to list the all the files in S3 bucket with regex?

Command:

aws s3 ls s3://test/sales*txt

Expected output:

sales1.txt
sales2.txt
sales3.txt

Solution

  • Use the following command

    aws s3 ls s3://test/ | grep '[sales].txt'