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 lists objects in the bucket, deletes them in DeleteObjects batches, and issues DeleteBucket only after the bucket is empty.
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);}'