rm

Prev Next

Available in Classic and VPC

Delete an object stored in Object Storage.

Syntax

The rm syntax is as follows:

aws s3 rm \
    <s3-uri> \
    [--dryrun] \
    [--quiet] \
    [--include <pattern>] \
    [--exclude <pattern>] \
    [--recursive] \
    [--only-show-errors] \
    [--page-size <page-size>] \
    --endpoint-url <endpoint-url>

Options

This section describes the options available when running rm.

Required options

The following options are required for rm.

Options Type Required Description
<s3-uri> String Required Object's S3 URI
  • s3://{bucket_name}/{object_name} format

Optional options

These are the optional options for rm. Options that are not specified will use their default values.

Options Type Required Description
--dryrun Boolean Optional Checks the results of the command without actually executing it.
--quiet Boolean Optional Does not display the response.
--include String Optional Includes only objects matching the specified pattern in the command.
  • Applied in the specified order.
--exclude String Optional Excludes objects matching the specified pattern from the command.
  • Applied in the specified order.
--recursive Boolean Optional Deletes all subobjects in the specified path.
--only-show-errors Boolean Optional Displays only errors; other response values are not displayed.
--page-size Integer Optional Number of items per page
  • 1-1000

Common options

For information about the options common to all aws subcommands, see Object Storage options.

Examples

When you run the command, the path of the deleted object is displayed.

Command

The following is an example command for deleting a single object.

aws s3 rm s3://my-test-bucket/sample.txt \
    --endpoint-url=https://kr.object.ncloudstorage.com

The following is an example command for deleting all objects in a directory.

aws s3 rm s3://my-test-bucket/docs/ \
    --recursive \
    --endpoint-url=https://kr.object.ncloudstorage.com

Output

The following is an example output for deleting a single object.

delete: s3://my-test-bucket/sample.txt

The following is an example output for deleting all objects in a directory.

delete: s3://my-test-bucket/docs/report.txt