Reputation: 333
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
Upvotes: 5
Views: 14208
Reputation: 1
I have been trying to sort this, {aws s3 ls } command is not supporting any regex or pattern matching option. Wr have to use bash commands grep or awk.
aws s3 ls s3://bucket/path/ | grep sales|grep txt
aws s3 ls s3://bucket/path/ | grep sales..txt
Upvotes: 0
Reputation: 648
The accepted solution is too broad and matches too much. Try this:
aws s3 ls s3://test/ | grep sales.*\.txt
Upvotes: 0
Reputation: 4604
Use the following command
aws s3 ls s3://test/ | grep '[sales].txt'
Upvotes: 9