rm
Command Function
This command is used to delete a file or folder.
Syntax
rm [-fv] FILE or rm [-rv] [PATH | filename]...
Parameters
Table 1 Parameter description
Usage
- The rm command can be used to delete multiple files or folders at a time.
- You can run rm -r to delete a non-empty directory.
- If the rm command without -f is used to delete a file that does not exist, an error will be reported.
Example
Run the following commands:
- rm testfile
- rm -r testpath/
Output
Example 1: deleting testfile
OHOS:/$ ls
bin etc proc storage testfile usr
dev lib sdcard system userdata vendor
OHOS:/$ rm testfile
OHOS:/$ ls
bin etc proc storage userdata vendor
dev lib sdcard system usr
Example 2: deleting testpath, a non-empty directory
OHOS:/$ ls
bin etc proc storage testpath usr
dev lib sdcard system userdata vendor
OHOS:/$ rm -r testpath/
OHOS:/$ ls
bin etc proc storage userdata vendor
dev lib sdcard system usr