Rpj
Rpj

Reputation: 6090

Is it possible to apply wild card patterns while removing S3 folders

http://docs.aws.amazon.com/cli/latest/reference/s3/rm.html

s3://foo/2015-01-01/..
s3://foo/2015-01-02/..
s3://foo/2015-01-03/..
..
s3://foo/2016-01-01/..
s3://foo/2016-01-02/..
s3://foo/2016-01-03/..

In the above setup, I would like to apply wild card on my removals.

e.g. aws s3 rm s3://foo/2015* 
or
aws s3 rm s3://foo/2016-02-* 

I am unable to achieve this with the existing command, is it achievable since I have large number of files to delete and I would like to run commands in parallel for faster deletes.

Upvotes: 9

Views: 6467

Answers (2)

Dusan Bajic
Dusan Bajic

Reputation: 10869

Currently, there is no support for the use of UNIX style wildcards in a command's path arguments, but you can use --exclude "<value>" and --include "<value>" parameters that can achieve the desired result:

aws s3 rm s3://foo/ --recursive --exclude "*" --include "2016-02-*" --dryrun

Upvotes: 19

jzonthemtn
jzonthemtn

Reputation: 3404

You cannot use Unix-style wildcards in the path but you can use filters on the S3 rm request to replicate the wildcard functionality. (See http://docs.aws.amazon.com/cli/latest/reference/s3/index.html#use-of-exclude-and-include-filters for examples.)

Upvotes: 3

Related Questions