Deleting folders and files from s3 bucket based on last modified date column and based on name prefix using AWS CLI

158 Views Asked by At

I want to delete folders from aws s3 my-bucket which are older than 2023-05-01 and folder names which starts with "000". using AWS CLI

I can delete folders and files which starts with "000" using :

aws s3 rm s3://my-bucket --exclude "*" --include "000*" --recursive

now i want to add date condition into it. How can I achieve it?

I tried

aws s3 rm s3://my-bucket/ | awk '$1< "2023-10-28 11:30:15" {print $0}'

but it didnt work. Its saying he system can not find file specified

0

There are 0 best solutions below