IamCalvinBrown.com a Blog Site

Code Examples, Consulting Advice and lots of other cool things

AWS CLI - Delete all files matching a filter in an S3 bucket

Amazon AWS can be amazing and interesting to deal with at times. When you host a static website using S3 and Route 53, it sometimes creates files for each request the service receives. To purge these files and avoid having tens of thousands or even millions of useless files, use this command on your local CLI:

#Delete all files that name start with "2018" files from the bucket:

aws s3 rm s3://[your-aws-bucket-name]/ --recursive --exclude '*' --include '2018*'

Loading