'\"macro stdmacro
.if n .pH g1.rm @(#)rm	40.8 of 10/10/89
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} rm 1 "Essential Utilities" "\&"
.if \nX=1 .ds x} rm 1 "Essential Utilities"
.if \nX=2 .ds x} rm 1 "" "\&"
.if \nX=3 .ds x} rm "" "" "\&"
.TH \*(x}
.SH NAME
\f4rm\f1, \f4rmdir\f1 \- remove files or directories
.SH SYNOPSIS
\f4rm\f1
\f1[\f4\-f\f1]
\f1[\f4\-i\f1]
\f2file\f1 ...
.sp .2
\f4rm\f1
\f4\-r\f1
\f1[\f4\-f\f1]
\f1[\f4\-i\f1]
\f4dirname\fP ... [\f2file\f1 ...]
.PP
\f4rmdir\f1
\f1[\f4\-p\f1]
\f1[\f4\-s\f1]
\f4dirname\fP ...
.SH DESCRIPTION
\f4rm\fP
removes the entries for one or more
files
from a directory.
If a file has no write permission
and the standard input is a terminal,
the full set of permissions (in octal) for the file are printed
followed by a question mark. 
This is a prompt for confirmation.
If the answer begins with \f4y\fP (for yes), the file is deleted,
otherwise the file remains.
.PP
If
.I file
is a symbolic link, the link will be removed, but the file or
directory to which it refers will not be deleted. 
A user does not need write permission on a symbolic link to remove
it, provided they have write permissions in the directory.
.PP
Note that if the standard input is not a terminal,
the command will operate as if the \f4\-f\f1 option is in effect.
.PP
Three options apply to
\f4rm\fP:
.TP 5
\f4\-f\f1
This option causes the removal of all files (whether write-protected
or not) in a directory without prompting the user.
In a write-protected directory, however,
files are never removed (whatever their permissions are),
but no messages are displayed. 
If the removal of a write-protected directory is attempted,
this option will not suppress an error message.
.TP 5
\f4\-r\f1
This option causes the recursive removal of any directories
and subdirectories in the argument list.
The directory will be emptied of files and removed.
Note that the user is normally prompted for removal of
any write-protected files which the directory contains.
The write-protected files are removed without prompting, however,
if the \f4\-f\f1 option is used, or if the standard input is
not a terminal and the \f4\-i\f1 option is not used.
.sp .5
Symbolic links that are encountered with this option will not be
traversed.
.sp .5
If the removal of a non-empty, write-protected directory is attempted,
the command will always fail (even if the \f4\-f\f1 option is used),
resulting in an error message.
.TP 5
\f4\-i\f1
With this option, confirmation of removal of any write-protected
file occurs interactively.
It overrides the
\f4\-f\f1 option and remains in effect even if the standard
input is not a terminal.
.PP
Two options apply to
\f4rmdir\fP:
.TP 5
\f4\-p\f1
This option allows users to remove the directory
.IRdirname\^
and its parent directories which become empty.
A message is printed on
standard output
about whether the whole
path is removed or part of the path remains for some
reason.
.TP 5
\f4\-s\f1
This option is used to suppress the message printed on
standard error
when \f4\-p\f1 is in effect.
.SH DIAGNOSTICS
All messages are generally self-explanatory.
.br
It is forbidden to remove the files "\f4.\fP" and "\f4..\fP"
in order to avoid the
consequences of inadvertently doing something like the following:
.RS
\f4rm \-r .\(**\f1
.RE
.PP
Both \f4rm\fP and
\f4rmdir\fP
return exit codes of 0 if all the specified directories
are removed successfully.
Otherwise, they return a non-zero exit code.
.SH SEE ALSO
.\"	@(#)rm.1	6.2 of 9/2/83
\f4unlink\fP(2), \f4rmdir\fP(2) in the
.IR "Programmer's Reference Manual\^" .
.SH NOTES
A \f4\-\^\-\f1
permits the user to mark explicitly the end of any command
line options, allowing
\f4rm\f1
to recognize filename arguments that begin with a \f4\-\f1.
As an aid to BSD migration, \f4rm\fP will accept \f4\-\fP as
a synonym for \f4\-\^\-\f1.
This migration aid may disappear in a future release.
If a \f4\-\^\-\f1
and a \f4\-\f1
both appear on the same command line, the second will be interpreted as
a filename.
.Ee
