Bash rm

title: Bash rm

Bash command: rm

rm attempts to remove non-directory type files specified.
If permissions do not allow writing the user is prompted for confirmation.


rm [options] [file_name]

Delete a File

rm <file name or file path>

Delete a Directory

rm -R <folder name or folder path>

Delete Files of a certain type

rm -R *file_extension
  • * accounts for the part to ignore, file_extension is the type to remove
rm -R *.txt

Removes all file ending with .txt

There are few commonly used arguments:

  • -r means to recursively delete all the folders inside a directory.
  • -f means to forcefully delete any folder or file.
  • -i will ask before deleting the file.
  • -v will explain what was deleted.


This command is capable of deleting many files at once with ease. This can be beneficial, but also dangerous. Use at your own risk.

To remove a nonempty folder for example, type:

rm -rf folder


The rm command can be used in conjunction with an asterisk to delete multiple items matching a specific set of criteria. For example, you could use rm test* to remove all files in a directory starting with “test” regardless of whatever text follows that string. You can also use an asterisk by itself to purge all files in the current directory using rm *.

More Information:

This article needs improvement. You can help improve this article. You can also write similar articles and help the community.