rm - Remove directory entries
Synopsis
rm [-f | -i] [-dPRr] file ...
Description
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
standard error) for confirmation.
The rm utility removes symbolic links, not the
files referenced by the links.
It is an error to attempt to remove the files "." and "..".
Options
- -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 -f option
overrides any previous -i options.
- -i
- Request confirmation before attempting to remove each
file, regardless of the file's permissions, or whether
the standard input device is a terminal. If the response from the
standard input begins with the first character for the YES response
in the current locale, the file is removed. The
-i option overrides any previous -f
options.
- -P
- Overwrite regular files before deleting them. Files are
overwritten three times, first with the byte pattern 0xff, then
0x00, and then 0xff again, before they are deleted.
- -R
- Attempt to remove the file hierarchy rooted in each
file argument. The -R option implies the
-d option. If the -i option is
specified, the user is prompted for confirmation before each
directory's contents are processed (as well as before the attempt
is made to remove the directory). If the user does not respond
affirmatively, the file hierarchy rooted in that directory is
skipped.
- -r
- Equivalent to -R.
Exit Status
- 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.
- >0 if an error occurs.
Related information
Examples
- Remove all the files and the directory "java", as well as any
subdirectories or files, or both, and do not prompt for conformation.
rm -r -f /home/bob/examples/code/java
- Remove the files "file1", "file2" and "file3".
rm file1 file2 file3