Use the rm command to delete files that you no longer need.
Command format
ossutil rm oss://bucket[/prefix] [flags]Parameter | Type | Description |
prefix | string | A folder or a specified prefix in the bucket. |
--all-versions | / | Specifies all versions of an object. |
-d, --dirs | / | Lists the files and subdirectories in the current directory instead of recursively listing all files in all subdirectories. |
--encoding-type | string | The codec for object names or file names. Valid value: url. |
--end-with | string | Returns objects that are alphabetically before or the same as the specified value. |
--exclude | stringArray | The exclusion rules for paths or file names. |
--exclude-from | stringArray | Reads exclusion rules from a rule file. |
--files-from | stringArray | Reads a list of source file names from a file. Empty lines or comment lines are ignored. |
--files-from-raw | stringArray | Reads a list of source file names from a file. |
--filter | stringArray | The filtering rules for paths or file names. |
--filter-from | stringArray | Reads filtering rules from a rule file. |
-f, --force | / | Forces the operation without a confirmation prompt. |
--include | stringArray | The inclusion rules for paths or file names. |
--include-from | stringArray | Reads inclusion rules from a rule file. |
--limited-num | int | The maximum number of results to return. |
--list-objects | / | Uses the ListObjects operation to list objects. |
--max-size | SizeSuffix | The maximum size of a file to transfer. The default unit is byte. You can use suffixes such as B, K, M, G, T, or P. 1 K (KiB) = 1024 B. |
--metadata-exclude | stringArray | The exclusion rules for object metadata. |
--metadata-filter | stringArray | The filtering rules for object metadata. |
--metadata-filter-from | stringArray | Reads object metadata filtering rules from a rule file. |
--metadata-include | stringArray | The inclusion rules for object metadata. |
--min-age | Duration | Deletes only files modified before the specified time interval. The default unit is second. You can use a suffix to specify the unit. For example, 1h indicates 1 hour. Note
|
--max-age | Duration | Deletes only files modified within the specified time interval. The default unit is second. You can use a suffix to specify the unit. For example, 1h indicates 1 hour. Note
|
--min-mtime | Time | Deletes only files modified after the specified time. The time must be in UTC format. For example, 2006-01-02T15:04:05. Note
|
--max-mtime | Time | Deletes only files modified before the specified time. The time must be in UTC format. For example, 2006-01-02T15:04:05. |
--min-size | SizeSuffix | The minimum size of a file to transfer. The default unit is byte. You can use suffixes such as B, K, M, G, T, or P. 1 K (KiB) = 1024 B. |
-m, --multipart | / | Deletes all fragments from multipart uploads that are not completed or canceled. |
--page-size | int | The maximum number of objects to list per page during batch processing. The value must be between 1 and 1000. The default value is 1000. |
-r, --recursive | / | Performs the operation recursively. If you specify this option, the command is run on all matching objects in the bucket. Otherwise, the command is run only on the object specified by the path. |
--request-payer | string | The payment method for the request. Set this parameter to `requester` if you use the pay-by-requester mode. |
--start-after | string | Returns objects that are alphabetically after the specified value. |
--version-id | string | The version ID of the object. |
For more information, see Command-line options.
Examples
Delete the exampleobject.txt file from the examplebucket bucket.
ossutil rm oss://examplebucket/exampleobject.txtDelete all files with the prefix "test" from the examplebucket bucket.
ossutil rm oss://examplebucket/test -rDelete all files with the .png extension from the examplebucket bucket.
ossutil rm oss://examplebucket --include "*.png" -rDelete files from the examplebucket bucket that meet any of the following conditions:
The file name contains the string "abc".
The file name extension is not .jpg.
The file name extension is not .txt.
ossutil rm oss://examplebucket --include "*abc*" --exclude "*.jpg" --exclude "*.txt" -rDelete a specific version of the exampleobject.txt file from the versioning-enabled examplebucket bucket.
ossutil rm oss://examplebucket/exampleobject.txt --version-id CAEQARiBgID8rumR2hYiIGUyOTAyZGY2MzU5MjQ5ZjlhYzQzZjNlYTAyZDE3****Delete all versions of the exampleobject.txt file from the versioning-enabled examplebucket bucket.
ossutil rm oss://examplebucket/exampleobject.txt --all-versions -rDelete all versions of all objects from the versioning-enabled examplebucket bucket.
ossutil rm oss://examplebucket --all-versions -rDelete all fragments from multipart uploads that are not completed or canceled.
ossutil rm oss://examplebucket -m -r -f