rm
<S3Uri>
[--dryrun]
[--quiet]
[--recursive]
[--request-payer <value>]
[--include <value>]
[--exclude <value>]
[--only-show-errors]
[--page-size <value>]
paths
(string)
--dryrun
(boolean)
Displays the operations that would be performed using the specified command without actually running them.
--quiet
(boolean)
Does not display the operations performed from the specified command.
--recursive
(boolean)
Command is performed on all files or objects under the specified directory or prefix.
--request-payer
(string)
Confirms that the requester knows that they will be charged for the request. Bucket owners need not specify this parameter in their requests. Documentation on downloading objects from requester pays buckets can be found at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
--include
(string)
Don’t exclude files or objects in the command that match the specified pattern. See Use of Exclude and Include Filters for details.
--exclude
(string)
Exclude all files or objects from the command that matches the specified pattern.
--only-show-errors
(boolean)
Only errors and warnings are displayed. All other output is suppressed.
--page-size
(integer)
The number of results to return in each response to a list operation. The default value is 1000 (the maximum allowed). Using a lower value may help if an operation times out.
See ‘aws help’ for descriptions of global parameters.
The following rm
command deletes a single s3 object:
aws s3 rm s3://mybucket/test2.txt
Output:
delete: s3://mybucket/test2.txt
The following rm
command recursively deletes all objects under a specified bucket and prefix when passed with the
parameter --recursive
. In this example, the bucket mybucket
contains the objects test1.txt
and
test2.txt
:
aws s3 rm s3://mybucket --recursive
Output:
delete: s3://mybucket/test1.txt
delete: s3://mybucket/test2.txt
The following rm
command recursively deletes all objects under a specified bucket and prefix when passed with the
parameter --recursive
while excluding some objects by using an --exclude
parameter. In this example, the bucket
mybucket
has the objects test1.txt
and test2.jpg
:
aws s3 rm s3://mybucket/ --recursive --exclude "*.jpg"
Output:
delete: s3://mybucket/test1.txt
The following rm
command recursively deletes all objects under a specified bucket and prefix when passed with the
parameter --recursive
while excluding all objects under a particular prefix by using an --exclude
parameter. In
this example, the bucket mybucket
has the objects test1.txt
and another/test.txt
:
aws s3 rm s3://mybucket/ --recursive --exclude "another/*"
Output:
delete: s3://mybucket/test1.txt
Deleting an object from an S3 access point
The following rm
command deletes a single object (mykey
) from the access point (myaccesspoint
):
aws s3 rm s3://arn:aws:s3:us-west-2:123456789012:accesspoint/myaccesspoint/mykey
Output:
delete: s3://arn:aws:s3:us-west-2:123456789012:accesspoint/myaccesspoint/mykey