rm1
Remove directory entries
Usage
rm [-dfiPRrv]
file ...
Overview
The rm utility attempts to remove the non-directory type files specified on the command line. If the permissions of the file do not permit writing, and the standard input device is a terminal, the user is prompted (on the standard error output) for confirmation.
The options are as follows:
-
-d -
Attempt to remove directories as well as other types of files.
-
-f -
Attempt to remove the files without prompting for confirmation, regardless of the file's permissions. If the file does not exist, do not display a diagnostic message or modify the exit status to reflect an error. The
-foption overrides any previous-ioptions. -
-i -
Request confirmation before attempting to remove each file, regardless of the file's permissions, or whether or not the standard input device is a terminal. The
-ioption overrides any previous-foptions. -
-P -
Attempt to overwrite regular writable files before deleting them. Files are overwritten once with a random pattern. Files with multiple links will be unlinked but not overwritten.
-
-R -
Attempt to remove the file hierarchy rooted in each file argument. The
-Roption implies the-doption. If the-ioption is specified, the user is prompted for confirmation before each directory (and its contents) are processed. If the user does not respond affirmatively, the file hierarchy rooted in that directory is skipped. -
-r -
Equivalent to
-R. -
-v -
Display each file name after it was removed.
The rm utility removes symbolic links, not the files referenced by the links.
It is an error to attempt to remove the root directory or the files “.” or “..”. It is forbidden to remove the file “..” merely to avoid the antisocial consequences of inadvertently doing something like “rm -r .*”.
Exit status
The rm utility exits 0 if all of the named files or file hierarchies were removed, or if the -f option was specified and all of the existing files or file hierarchies were removed. If an error occurs, rm exits with a value >0.
Examples
Recursively remove all files contained within the foobar directory hierarchy:
$ rm -rf foobar
Either of these commands will remove the file -f:
$ rm -- -f $ rm ./-f
Releases
61 releases since OpenBSD 2.1; the text changed 24 times.
- 2.1
- 2.2–2.4
- 2.5
- 2.6
- 2.7
- 2.8
- 2.9
- 3.0
- 3.1
- 3.2
- 3.3
- 3.4
- 3.5–3.7
- 3.8–4.0
- 4.1
- 4.2–4.4
- 4.5–4.8
- 4.9–5.2
- 5.3–5.5
- 5.6–5.8
- 5.9
- 6.0–6.1
- 6.2–6.3
- 6.4–6.5
- 6.6–8.0
-v since OpenBSD 6.2.
-W until OpenBSD 3.7.