Skip to main content

rm

The bx rm command can be used to remove both files and directories along with all their content.

info

The rm command can be used with or without prepending bx:// to the path.

Usage​

bx rm [-f] [--help] <path>

Parameters and inputs​

ShorthandLong versionDescription
-f--forceForce deletion
--helpShow this help message and exit

Examples​

Remove a file​

Create two local files, one with the content "the sweet hello" and other with the content "the sad goodbye".

$ echo "the sweet hello" > hello.txt
$ echo "the sad goodbye" > goodbye.txt

Upload both files to BatchX using the cp command.

$ bx cp hello.txt bx://test/hello.txt
hello.txt [=================================================>] 100 %

$ bx cp goodbye.txt bx://test/goodbye.txt
goodbye.txt [=================================================>] 100 %
info

The cp command will dynamically create those directories that haven't been previously created.

Use the bx ls command to list the contents of the test/ directory.

$ bx ls test
FILE CREATED SIZE USER
test/hello.txt Sun Dec 15 20:53:46 CET 2019 6 B david
test/goodbye.txt Sun Dec 15 20:53:50 CET 2019 6 B david

Use the bx rm command to remove the hello.txt file.

$ bx rm test/hello.txt
Successfully deleted file link and data

Remove the only file in folder​

Continuing with the previous example, use the bx ls command to list again the contents of the test/ directory. Notice that now the only content in this directory is the goodbye.txt file.

$ bx ls test
test/goodbye.txt Sun Dec 15 20:53:50 CET 2019 6 B david

Use the rm command to remove the goodbye.txt __file. Now, this will also eliminate the test/ empty directory.

$ bx rm test/hello.txt
Successfully deleted file link and data

As shown bellow, both the file and the directory have been eliminated.
Listing a non existing file or directory will return a NOT_FOUND __error code.

$ bx ls test
BatchX endpoint has returned this error: Status{code=NOT_FOUND, description=null, cause=null}

Remove a folder​

Upload again the hello.txt and the goodbye.txt files we created in the first example.

$ bx cp hello.txt bx://test/hello.txt
hello.txt [=================================================>] 100 %

$ bx cp goodbye.txt bx://test/goodbye.txt
goodbye.txt [=================================================>] 100 %

Use the bx ls command to list the contents of the test/ __directory.

$ bx ls test
FILE CREATED SIZE USER
test/hello.txt Sun Dec 15 20:55:15 CET 2019 6 B david
test/goodbye.txt Sun Dec 15 20:55:20 CET 2019 6 B david

Use the bx rm command to eliminate the test/ __directory. BatchX will prompt you to confirm this action. After confirmation, all file references within the directory will be removed.

$ bx rm test
Path corresponds to a folder:
[ 6 B] test/goodbye.txt
[ 6 B] test/hello.txt
Are you sure you want to delete all these files? (yes/no)
yes
Successfully deleted file link
info

To avoid BatchX from prompting you for confirmation you can use the force parameter -f.