rm(1)rm(1)NAMErm - Removes (unlinks) files or directories
SYNOPSISrm [-efirR] [--] file...
STANDARDS
Interfaces documented on this reference page conform to industry stan‐
dards as follows:
rm: XCU5.0
Refer to the standards(5) reference page for more information about
industry standards and associated tags.
OPTIONS
[Tru64 UNIX] Displays a message after deleting each file. Does not
prompt before removing a file that does not have write permission set,
and does not display an error message if a specified file does not
exist. If you specify both -f and -i when invoking rm, the option that
is specified last on the command line takes effect. Prompts you before
deleting each file (interactive). When you use both -i and -r, rm also
prompts for removing each file, then the directory. If you specify both
-f and -i with rm, the last one on the command line takes effect. Per‐
mits recursive removal of directories and their contents (for cases
where file is a directory). Permits recursive removal of directories
and their contents (for cases where file is a directory, same as -r).
[Tru64 UNIX] Indicates that all arguments following it are to be
treated as file names. This allows you to specify file names starting
with a - (dash).
OPERANDS
Path name of a file or directory to be removed.
DESCRIPTION
The rm command removes the entries for the specified files from a
directory.
If file is of the directory type: If you specify neither -R or -r, rm
writes a diagnostic message to standard error, does nothing further
with file, and goes on to any remaining files. If -f is not specified
and either of the following is true, rm writes a prompt to standard
error and reads a line from standard input: The permissions of file do
not permit writing and standard input is a terminal The -i option is
specified
If the response is affirmative, rm does nothing further with the
current file and goes on to any remaining files. (The same
actions are taken if -f is specified and file is not of the
directory type.) For each entry contained in file, other than
(dot) or (dot dot) entries, the four steps listed here (1-3) are
taken with the entry as if it were a file argument.
[Tru64 UNIX] If an entry is the last link to a file, it is destroyed.
To remove a file, you must have write permission for its parent direc‐
tory, but need neither read nor write permission for the file itself.
If the sticky bit on the directory is set, you must be the owner of the
file or superuser.
If a file has no write permission and standard input is a terminal or
the -i option is specified, rm displays the file permission code and
reads a line from standard input. If that line begins with y, or the
locale's equivalent of a y, rm deletes the file. If the response is
anything else, rm does nothing to that file and continues with the next
specified file.
The LC_MESSAGES variable determines the locale's equivalent of y or n
(for yes/no queries).
The -i option causes rm to prompt and read the standard input even if
the standard input is not a terminal. In the absence of -i, however,
the mode prompting is not done when the standard input is not a termi‐
nal.
If the environment variable STDS_FLAG is set to ALL, the rm command
processes pathnames of any length, however the outcome is unpre‐
dictable if synchronization issues exist.
RESTRICTIONS
It is an error to specify . (dot) or .. (dot dot) as the final path
name component of file, although these entries may be removed with the
-r or -R options.
EXIT STATUS
The following exit values are returned: If the -f option was not speci‐
fied, all the named directory entries were removed; otherwise, all the
existing named directory entries were removed. An error occurred.
EXAMPLES
To delete a file, enter: rm myfile
If there is another link to this file, then the file remains
under that name, but myfile is removed. If myfile is the only
link, the file itself is deleted. To delete a file silently,
enter: rm-f core
This removes core without asking any questions or displaying any
error messages. This is normally used in shell procedures. It
prevents confusing messages from being displayed when deleting
files that may or may not exist. To delete files interactively,
enter: rm-i mydir/*
After each file name is displayed, enter the affirmative
response to remove the file; press <Return> (or anything other
than the affirmative response) to retain the file. To delete a
directory tree interactively, enter: rm-ir manual
This recursively removes the contents of all subdirectories of
manual, then removes manual itself, asking if you want to remove
each file and directory.
ENVIRONMENT VARIABLES
The following environment variables affect the execution of rm: Pro‐
vides a default value for the internationalization variables that are
unset or null. If LANG is unset or null, the corresponding value from
the default locale is used. If any of the internationalization vari‐
ables contain an invalid setting, the utility behaves as if none of the
variables had been defined. If set to a non-empty string value, over‐
rides the values of all the other internationalization variables.
Determines the locale for the behavior of ranges, equivalence classes,
and multicharacter collating elements used in the extended regular
expression defined for the yesexpr locale keyword in the LC_MESSAGES
category. Determines the locale for the interpretation of sequences of
bytes of text data as characters (for example, single-byte as opposed
to multibyte characters in arguments).
Determines the behavior of character classes in regular expres‐
sions used in the extended regular espression defined for the
yesexpr locale keyword in the LC_MESSAGES category. Determines
the locale for the format and contents of diagnostic messages
written to standard error. Determines the location of message
catalogues for the processing of LC_MESSAGES. Resolves the
behavior of the command in some scenarios that cause noncompli‐
ance with POSIX standards. Setting this variable to ALL enables
the command to overcome all instances of noncompliance.
SEE ALSO
Commands: ln(1), mv(1), rmdir(1)
Functions: rmdir(2), unlink(2), remove(3)
Standards: standards(5)rm(1)