2018-10-15 22:32:55 +05:30
---
title: Bash rm
---
## Bash command: rm
2019-03-21 23:07:24 -04:00
`rm` attempts to remove non-directory type files specified.
If permissions do not allow writing the user is prompted for confirmation.
2018-10-15 22:32:55 +05:30
2018-10-27 16:25:36 +01:00
### Usage
2019-03-18 03:26:06 -07:00
```bash
rm [options] [file_name]
```
2018-10-27 16:25:36 +01:00
**Delete a File**
```bash
rm < file name or file path >
```
**Delete a Directory**
```bash
rm -R < folder name or folder path >
```
2018-10-15 22:32:55 +05:30
2019-03-21 23:03:43 -04:00
**Delete Files of a certain type**
```bash
rm -R *file_extension
```
- `*` accounts for the part to ignore, `file_extension` is the type to remove
Example:
```bash
rm -R *.txt
```
Removes all file ending with .txt
2018-12-20 20:59:33 -05:00
2018-10-15 22:32:55 +05:30
There are few commonly used arguments:
2019-03-22 21:26:31 +05:30
- `-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.
2018-10-15 22:32:55 +05:30
2018-10-28 21:33:37 -04:00
### Warning
2018-11-03 09:15:39 +05:00
This command is capable of deleting many files at once with ease. This can be beneficial, but also dangerous. Use at your own risk.
2018-11-17 18:48:26 +01:00
To remove a nonempty folder for example, type:
2019-03-18 03:26:06 -07:00
```bash
rm -rf folder
```
2018-11-17 18:48:26 +01:00
2019-03-21 22:45:14 -04:00
### Wildcards
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 *` .
2018-10-15 22:32:55 +05:30
### More Information:
* [Wikipedia ](https://en.wikipedia.org/wiki/Rm_(Unix ))
2018-11-18 00:38:59 +08:00
* [Man pages ](http://man7.org/linux/man-pages/man1/rm.1.html )
* [Linux ](https://linux.die.net/man/1/rm )