rm (delete)
Delete one object
To remove an object:
s3m rm backup/backups/file.datDelete multiple objects
Delete multiple objects in one command:
s3m rm backup/backups/a.txt backup/backups/b.txtWhen exactly one object is provided, s3m uses DeleteObject. When 2+ object paths are provided, s3m groups them by bucket and uses DeleteObjects in batches of up to 1000 keys.
Delete an empty bucket
Delete a bucket only after removing all objects:
s3m rm -b backup/empty-bucketRecursive bucket delete
Recursively delete bucket contents in batches and then delete the bucket:
s3m rm -b --recursive backup/my-bucket--recursive is only for bucket deletion. It is version-aware: it enumerates object versions and delete markers (ListObjectVersions), removes them in DeleteObjects batches, and issues DeleteBucket only after the bucket is empty — so it can empty versioned and Object Lock buckets.
For an Object Lock bucket, retained versions are refused unless you add --bypass-governance (and COMPLIANCE retention can never be bypassed):
s3m rm -b --recursive --bypass-governance backup/vaultVersioned buckets & Object Lock
On a versioned bucket (for example one created with cb --object-lock), a keyed delete does not remove data — S3 inserts a delete marker and keeps the existing versions. s3m reports this so a successful rm isn't mistaken for removal:
$ s3m rm backup/vault/file.dat
backup/vault/file.dat: delete marker created (version 04db9d4f-…); existing versions are retainedDelete a specific version permanently with --version-id:
s3m rm backup/vault/file.dat --version-id 4c173ee6-85a0-4da8-8884-a50d517c63fbIf that version is protected by Object Lock in GOVERNANCE mode, the delete is refused unless you also pass --bypass-governance (which requires the s3:BypassGovernanceRetention permission):
s3m rm backup/vault/file.dat --version-id 4c173ee6-… --bypass-governanceCOMPLIANCE-mode retention cannot be bypassed by anyone until it expires.
Retention filter
Delete only objects older than a retention threshold:
s3m rm backup/backups/archive/ --older-than 90dShell-driven bulk delete
Prefer the built-in recursive bucket delete when the goal is to empty a bucket and then remove it:
s3m rm -b --recursive backup/my-bucketKeep the shell-driven approach for custom workflows where you explicitly want to control the object list yourself.
Example to delete all files in bucket:
s3m ls backup/backups | awk '{print $NF}' | xargs -t -P4 -I '{}' s3m rm backup/backups/'{}'In this example xargs is used with options:
-tPrint the command line-P4Run up to 4 max-procs
Abort a multipart upload
s3m rm backup/backups/file.dat --abort <upload-id>To find the upload ID:
s3m ls backup/backups --multipartFor example to abort all multipart uploads:
s3m ls backup/backups --multipart | awk '{system("s3m rm backup/backups/"$5" --abort "$4);}'
