Rm command¶
Removes a group of files. Use with caution.
To list (but not remove) files to be deleted, use --dryRun
. You can also
list files via ls
command – the listing behaviour is exactly the same.
Users with high-performance networks or multiple files to be removed, will benefit from multi-threaded capabilities. The default number of threads is 10.
Progress is displayed on the console unless --noProgress
is specified.
The --versions
option shows all versions of each file, not
just the most recent.
The --recursive
option will descend into folders, and will show
only files, not folders.
The --withWildcard
option will allow using *
, ?
and `[]`
characters in folderName
as a greedy wildcard, single character
wildcard and range of characters. It automatically assumes --recursive
.
Remember to quote folderName
to avoid shell expansion.
The --dryRun
option prints all the files that
would be affected by the command, but removes nothing.
Normally, when an error happens during file removal, log is printed and the command
goes further. If any error should be immediately breaking the command,
--failFast
can be passed to ensure that first error will stop the execution.
This could be useful to e.g. check whether provided credentials have deleteFiles
capabilities.
Note
Using --failFast
doesn’t prevent the command from trying to remove further files.
It just stops the progress. Since multiple files are removed in parallel, it’s possible
that just some of them were not reported.
Command returns 0 if all files were removed successfully and a value different from 0 if any file was left.
Examples.
Note
Note the use of quotes, to ensure that special characters are not expanded by the shell.
Note
Use with caution. Running examples presented below can cause data-loss.
Remove all csv and tsv files (in any directory, in the whole bucket):
b2 rm --recursive --withWildcard bucketName "*.[ct]sv"
Remove all info.txt files from buckets bX, where X is any character:
b2 rm --recursive --withWildcard bucketName "b?/info.txt"
Remove all pdf files from buckets b0 to b9 (including sub-directories):
b2 rm --recursive --withWildcard bucketName "b[0-9]/*.pdf"
Requires capability:
listFiles
deleteFiles
b2 rm [-h] [--profile PROFILE] [--dryRun] [--threads THREADS]
[--queueSize QUEUESIZE] [--noProgress] [--failFast] [--long] [--json]
[--replication] [--versions] [--recursive] [--withWildcard]
bucketName [folderName]
Positional Arguments¶
- bucketName
- folderName
Named Arguments¶
- --profile
- --dryRun
Default: False
- --threads
Default: 10
- --queueSize
max elements fetched at once for removal, if left unset defaults to twice the number of threads.
- --noProgress
Default: False
- --failFast
Default: False
- --long
Default: False
- --json
Default: False
- --replication
Default: False
- --versions
Default: False
- --recursive
Default: False
- --withWildcard
Default: False