← 返回命令列表

Linux command

aws-s3-rm 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Delete a single object

aws s3 rm s3://[bucket-name]/[file.txt]

Recursively delete

aws s3 rm s3://[bucket-name]/[prefix/] --recursive

Delete all objects

aws s3 rm s3://[bucket-name] --recursive

Delete all except

aws s3 rm s3://[bucket-name]/ --recursive --exclude "*.jpg"

Preview delete operation

aws s3 rm s3://[bucket-name]/ --recursive --dryrun

说明

aws s3 rm deletes objects from Amazon S3. By default, it deletes a single object. Use the --recursive option to delete all objects under a specified prefix. The command supports pattern matching with --include and --exclude options to selectively delete objects matching specific criteria.

参数

S3Uri
The S3 URI of the object or prefix to delete (s3://bucket-name/key)
--recursive
Delete all objects under the specified prefix
--dryrun
Display operations that would be performed without executing them
--quiet
Suppress output during the delete operation
--include _pattern_
Include objects matching the pattern (used with --exclude)
--exclude _pattern_
Exclude objects matching the pattern from deletion
--only-show-errors
Display only errors and warnings, suppressing successful operations
--page-size _value_
Number of objects to retrieve per API call (default: 1000)

FAQ

What is the aws-s3-rm command used for?

aws s3 rm deletes objects from Amazon S3. By default, it deletes a single object. Use the --recursive option to delete all objects under a specified prefix. The command supports pattern matching with --include and --exclude options to selectively delete objects matching specific criteria.

How do I run a basic aws-s3-rm example?

Run `aws s3 rm s3://[bucket-name]/[file.txt]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does S3Uri do in aws-s3-rm?

The S3 URI of the object or prefix to delete (s3://bucket-name/key)