2 .\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved
3 .\" Copyright 1989 AT&T
4 .\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures
5 .\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
6 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
7 .\" http://www.opengroup.org/bookstore/.
8 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
9 .\" This notice shall appear on any product containing this material.
10 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
11 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
12 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
13 .TH RM 1 "Oct 25, 2017"
15 rm, rmdir \- remove directory entries
19 \fB/usr/bin/rm\fR [\fB-fiRr\fR] \fIfile\fR...
24 \fB/usr/bin/rmdir\fR [\fB-ps\fR] \fIdirname\fR...
30 \fB/usr/bin/rmdir\fR [\fB-eps\fR] \fIdirname\fR...
36 The \fBrm\fR utility removes the directory entry specified by each \fIfile\fR
37 argument. If a file has no write permission and the standard input is a
38 terminal, the full set of permissions (in octal) for the file are printed
39 followed by a question mark. This is a prompt for confirmation. If the answer
40 is affirmative, the file is deleted, otherwise the file remains.
43 If \fIfile\fR is a symbolic link, the link is removed, but the file or
44 directory to which it refers is not deleted. Users do not need write permission
45 to remove a symbolic link, provided they have write permissions in the
49 If multiple \fIfile\fRs are specified and removal of a \fIfile\fR fails for any
50 reason, \fBrm\fR writes a diagnostic message to standard error, do nothing more
51 to the current \fIfile\fR, and go on to any remaining \fIfile\fRs.
54 If the standard input is not a terminal, the utility operates as if the
55 \fB-f\fR option is in effect.
59 The \fBrmdir\fR utility removes the directory entry specified by each
60 \fIdirname\fR operand, which must refer to an empty directory.
63 Directories are processed in the order specified. If a directory and a
64 subdirectory of that directory are specified in a single invocation of
65 \fBrmdir\fR, the subdirectory must be specified before the parent directory so
66 that the parent directory is empty when \fBrmdir\fR tries to remove it.
70 The \fBrmdir\fR built-in in \fBksh93\fR is associated with the \fB/bin\fR and
71 \fB/usr/bin\fR paths. It is invoked when \fBrmdir\fR is executed without a
72 pathname prefix and the pathname search finds a \fB/bin/rmdir\fR or
73 \fB/usr/bin/rmdir\fR executable.
76 \fBrmdir\fR deletes each given directory. The directory must be empty and
77 contain no entries other than \fB\&.\fR or \fB\&..\fR. If a directory and a
78 subdirectory of that directory are specified as operands, the subdirectory must
79 be specified before the parent, so that the parent directory is empty when
80 \fBrmdir\fR attempts to remove it.
84 The following options are supported:
91 Recursively removes directories and subdirectories in the argument list. The
92 directory is emptied of files and removed. The user is normally prompted for
93 removal of any write-protected files which the directory contains. The
94 write-protected files are removed without prompting, however, if the \fB-f\fR
95 option is used, or if the standard input is not a terminal and the \fB-i\fR
98 Symbolic links that are encountered with this option is not traversed.
100 If the removal of a non-empty, write-protected directory is attempted, the
101 utility always fails (even if the \fB-f\fR option is used), resulting in an
111 Same as \fB-r\fR option.
120 Does not prompt for confirmation. Does not write diagnostic messages or modify
121 the exit status in the case of non-existent operands. Any previous occurrences
122 of the \fB-i\fR option is ignored.
131 Prompts for confirmation. Any occurrences of the \fB-f\fR option is ignored.
137 The following options are supported for \fB/usr/bin/rmdir\fR only:
144 Allows users to remove the directory \fIdirname\fR and its parent directories
145 which become empty. A message is printed to standard error if all or part of
146 the path could not be removed.
155 Suppresses the message printed on the standard error when \fB-p\fR is in
162 The following options are supported for the \fBrmdir\fR built-in for
171 \fB\fB--ignore-fail-on-non-empty\fR\fR
174 Ignore each non-empty directory failure.
184 \fB\fB--parents\fR\fR
187 Remove each explicit directory argument directory that becomes empty after its
188 child directories are removed.
198 \fB\fB--suppress\fR\fR
201 Suppress the message printed on the standard error when \fB-p\fR is in effect.
207 The following operands are supported:
214 Specifies the pathname of a directory entry to be removed.
223 Specifies the pathname of an empty directory to be removed.
229 See \fBlargefile\fR(5) for the description of the behavior of \fBrm\fR and
230 \fBrmdir\fR when encountering files greater than or equal to 2 Gbyte ( 2^31
235 The following examples are valid for the commands shown.
237 \fBExample 1 \fRRemoving Directories
240 The following command removes the directory entries \fBa.out\fR and \fBcore\fR:
245 example% \fBrm a.out core\fR
251 \fBExample 2 \fRRemoving a Directory without Prompting
254 The following command removes the directory \fBjunk\fR and all its contents,
260 example% \fBrm -rf junk\fR
267 \fBExample 3 \fRRemoving Empty Directories
270 If a directory \fBa\fR in the current directory is empty, except that it
271 contains a directory \fBb\fR, and \fBa/b\fR is empty except that it contains a
272 directory \fBc\fR, the following command removes all three directories:
277 example% \fBrmdir -p a/b/c\fR
282 .SH ENVIRONMENT VARIABLES
285 See \fBenviron\fR(5) for descriptions of the following environment variables
286 that affect the execution of \fBrm\fR and \fBrmdir\fR: \fBLANG\fR,
287 \fBLC_ALL\fR, \fBLC_COLLATE\fR, \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and
291 Affirmative responses are processed using the extended regular expression
292 defined for the \fByesexpr\fR keyword in the \fBLC_MESSAGES\fR category of the
293 user's locale. The locale specified in the \fBLC_COLLATE\fR category defines
294 the behavior of ranges, equivalence classes, and multi-character collating
295 elements used in the expression defined for \fByesexpr\fR. The locale specified
296 in \fBLC_CTYPE\fR determines the locale for interpretation of sequences of
297 bytes of text data a characters, the behavior of character classes used in the
298 expression defined for the \fByesexpr\fR. See \fBlocale\fR(5).
302 The following exit values are returned:
309 If the \fB-f\fR option was not specified, all the named directory entries were
310 removed; otherwise, all the existing named directory entries were removed.
325 The following exit values are returned:
332 Successful completion. All directories deleted successfully.
341 An error occurred. One or more directories could not be deleted.
347 See \fBattributes\fR(5) for descriptions of the following attributes:
356 ATTRIBUTE TYPE ATTRIBUTE VALUE
369 ATTRIBUTE TYPE ATTRIBUTE VALUE
373 Interface Stability Committed
375 Standard See \fBstandards\fR(5).
386 ATTRIBUTE TYPE ATTRIBUTE VALUE
388 Interface Stability See below.
393 The \fBksh93\fR built-in binding to \fB/bin\fR and \fB/usr/bin\fR is Volatile.
394 The built-in interfaces are Uncommitted.
398 \fBksh93\fR(1), \fBrmdir\fR(2), \fBrmdir\fR(2), \fBunlink\fR(2),
399 \fBattributes\fR(5), \fBenviron\fR(5), \fBlargefile\fR(5), \fBstandards\fR(5)
403 All messages are generally self-explanatory.
406 It is forbidden to remove the files "\fB\&.\fR" and "\fB\&..\fR" in order to
407 avoid the consequences of inadvertently doing something like the following:
411 example% \fBrm -r .*\fR
418 It is forbidden to remove the file "\fB/\fR" in order to avoid the consequences
419 of inadvertently doing something like:
423 example% \fBrm -rf $x/$y\fR
434 example% \fBrm -rf /$y\fR
441 when \fB$x\fR and \fB$y\fR expand to empty strings.
445 A \fB\(mi\fR permits the user to mark explicitly the end of any command line
446 options, allowing \fBrm\fR to recognize file arguments that begin with a
447 \fB\(mi\fR\&. As an aid to BSD migration, \fBrm\fR accepts \fB\(mi\|\(mi\fR as
448 a synonym for \fB\(mi\fR\&. This migration aid may disappear in a future
449 release. If a \fB\(mi\|\(mi\fR and a \fB\(mi\fR both appear on the same command
450 line, the second is interpreted as a file.