0 votes
1 view
in AWS by (19.2k points)

Suppose I have an S3 bucket named x.y.z

In this bucket, I have hundreds of files. But I only want to delete 2 files named purple.gif and worksheet.xlsx

Can I do this from the AWS command-line tool with a single call to rm?

This did not work:

$ aws s3 rm s3://x.y.z/worksheet.xlsx s3://x.y.z/purple.gif

Unknown options: s3://x.y.z/purple.gif

From the manual, it doesn't seem like you can delete a list of files explicitly by name. Does anyone know a way to do it? I prefer not using the --recursive flag.

1 Answer

0 votes
by (44.6k points)

You can do that using s3 api delete-objects:

aws s3api delete-objects --bucket x.y.z --delete '{"Objects":[{"Key":"worksheet.xlsx"},{"Key":"purple.gif"}]}'

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...