To delete files on Linux server, there are multi ways to achieve this.
rm bash command
1 | rm [options] ...file... |
I usually use rm -rf file folder_name
to remove a non-empty filefolder.
Options:
-f, —force
Ignore nonexistent files, never prompt
-r, -R, —recursive
Remove directories and their contents recursively.
and some other options, see the reference 1 for the doc.
rsync
rsync
is an alternative method which can be used in deleting files. It is suitable for the folder which contains a large amount of files, in which case rm -rf
can’t behave well.
1 | mkdir empty |
Reference
- Bash man doc: rm
- Bash man doc: rsync
- StackExchange: Efficiently delete large directory containing thousands of files