xref: /illumos-gate/usr/src/man/man1/rmdir.1 (revision ff3f2bffadb9220702c4ea407c0dc90c8847ea66)
1.\"
2.\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3.\" permission to reproduce portions of its copyrighted documentation.
4.\" Original documentation from The Open Group can be obtained online at
5.\" http://www.opengroup.org/bookstore/.
6.\"
7.\" The Institute of Electrical and Electronics Engineers and The Open
8.\" Group, have given us permission to reprint portions of their
9.\" documentation.
10.\"
11.\" In the following statement, the phrase ``this text'' refers to portions
12.\" of the system documentation.
13.\"
14.\" Portions of this text are reprinted and reproduced in electronic form
15.\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16.\" Standard for Information Technology -- Portable Operating System
17.\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18.\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19.\" Engineers, Inc and The Open Group.  In the event of any discrepancy
20.\" between these versions and the original IEEE and The Open Group
21.\" Standard, the original IEEE and The Open Group Standard is the referee
22.\" document.  The original Standard can be obtained online at
23.\" http://www.opengroup.org/unix/online.html.
24.\"
25.\" This notice shall appear on any product containing this material.
26.\"
27.\" The contents of this file are subject to the terms of the
28.\" Common Development and Distribution License (the "License").
29.\" You may not use this file except in compliance with the License.
30.\"
31.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32.\" or http://www.opensolaris.org/os/licensing.
33.\" See the License for the specific language governing permissions
34.\" and limitations under the License.
35.\"
36.\" When distributing Covered Code, include this CDDL HEADER in each
37.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38.\" If applicable, add the following below this CDDL HEADER, with the
39.\" fields enclosed by brackets "[]" replaced with your own identifying
40.\" information: Portions Copyright [yyyy] [name of copyright owner]
41.\"
42.\"
43.\" Copyright 1989 AT&T
44.\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
45.\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures
46.\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved
47.\"
48.Dd March 28, 2026
49.Dt RMDIR 1
50.Os
51.Sh NAME
52.Nm rmdir
53.Nd remove directories
54.Sh SYNOPSIS
55.Nm /usr/bin/rmdir
56.Op Fl ps
57.Ar dirname
58.Ss "ksh93"
59.Nm /usr/bin/rmdir
60.Op Fl eps
61.Ar dirname ...
62.Sh DESCRIPTION
63The
64.Nm
65utility removes the directory entry specified by each
66.Ar dirname
67operand, which must refer to an empty directory.
68.Pp
69Directories are processed in the order specified.
70If a directory and a subdirectory of that directory are specified in a single
71invocation of
72.Nm rmdir ,
73the subdirectory must be specified before the parent directory so that the
74parent directory is empty when
75.Nm rmdir
76tries to remove it.
77.Ss "ksh93"
78The
79.Nm rmdir
80built-in in
81.Nm ksh93
82is associated with the
83.Pa /bin
84and
85.Pa /usr/bin
86paths.
87It is invoked when
88.Nm rmdir
89is executed without a pathname prefix and the pathname search finds a
90.Pa /bin/rmdir
91or
92.Pa /usr/bin/rmdir
93executable.
94.Sh OPTIONS
95The following options are supported for both
96.Nm /usr/bin/rmdir
97and
98.Nm ksh93 rmdir :
99.Bl -tag -width Fl
100.It Fl p
101Allows users to remove the directory
102.Ar dirname
103and its parent directories which become empty.
104A message is printed to standard error if all or part of the path could not be
105removed.
106.It Fl s
107Suppresses the message printed on the standard error when
108.Fl p
109is in effect.
110.El
111.Ss "ksh93"
112The following options are supported for the
113.Nm rmdir
114built-in for
115.Nm ksh93 :
116.Bl -tag -width Fl
117.It Fl e , Fl -ignore-fail-on-non-empty
118Ignore each non-empty directory failure.
119.It Fl -parents
120Long option for
121.Fl p .
122.It Fl -suppress
123Long option for
124.Fl s .
125.El
126.Sh OPERANDS
127The following operands are supported:
128.Bl -tag -width Ar
129.It Ar dirname
130Specifies the pathname of an empty directory to be removed.
131.El
132.Sh USAGE
133See
134.Xr largefile 7
135for the description of the behavior of
136.Nm rmdir
137when encountering files greater than or equal to 2 Gbyte (2^31 bytes).
138.Sh EXIT STATUS
139The following exit values are returned:
140.Bl -tag -width Sy
141.It Sy 0
142All the existing named directory entries were removed.
143.It Sy >0
144An error occurred.
145.El
146.Sh EXAMPLES
147.Sy Example 1 No Removing Empty Directories
148.Pp
149If a directory
150.Pa a
151in the current directory is empty, except that it contains a directory
152.Pa b ,
153and
154.Pa a/b
155is empty except that it contains a directory
156.Pa c ,
157the following command removes all three directories:
158.Pp
159.Dl example% rmdir -p a/b/c
160.Sh INTERFACE STABILITY
161.Sy Committed
162.Pp
163.Nm ksh93
164built-in binding to
165.Pa /bin
166and
167.Pa /usr/bin
168is Volatile.
169The built-in interfaces are Uncommitted.
170.Sh SEE ALSO
171.Xr ksh93 1 ,
172.Xr rm 1 ,
173.Xr unlink 2 ,
174.Xr attributes 7 ,
175.Xr largefile 7 ,
176.Xr standards 7
177