xref: /openbsd/bin/rmdir/rmdir.1 (revision d415bd75)
1.\"	$OpenBSD: rmdir.1,v 1.21 2010/12/03 00:36:15 jmc Exp $
2.\"	$NetBSD: rmdir.1,v 1.10 1995/07/25 19:37:35 jtc Exp $
3.\"
4.\" Copyright (c) 1990, 1993
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" This code is derived from software contributed to Berkeley by
8.\" the Institute of Electrical and Electronics Engineers, Inc.
9.\"
10.\" Redistribution and use in source and binary forms, with or without
11.\" modification, are permitted provided that the following conditions
12.\" are met:
13.\" 1. Redistributions of source code must retain the above copyright
14.\"    notice, this list of conditions and the following disclaimer.
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\"    notice, this list of conditions and the following disclaimer in the
17.\"    documentation and/or other materials provided with the distribution.
18.\" 3. Neither the name of the University nor the names of its contributors
19.\"    may be used to endorse or promote products derived from this software
20.\"    without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\"	@(#)rmdir.1	8.1 (Berkeley) 5/31/93
35.\"
36.Dd $Mdocdate: December 3 2010 $
37.Dt RMDIR 1
38.Os
39.Sh NAME
40.Nm rmdir
41.Nd remove directories
42.Sh SYNOPSIS
43.Nm rmdir
44.Op Fl p
45.Ar directory ...
46.Sh DESCRIPTION
47The
48.Nm
49utility removes the directory entry specified by
50each
51.Ar directory
52argument, provided it is empty.
53.Pp
54Arguments are processed in the order given.
55In order to remove both a parent directory and a subdirectory
56of that parent, the subdirectory
57must be specified first so the parent directory
58is empty when
59.Nm
60tries to remove it.
61.Pp
62The options are as follows:
63.Bl -tag -width Ds
64.It Fl p
65Each
66.Ar directory
67argument is treated as a pathname of which all
68components will be removed, if they are empty,
69starting with the last most component.
70(See
71.Xr rm 1
72for fully non-discriminant recursive removal.)
73.El
74.Sh EXIT STATUS
75The
76.Nm
77utility exits with one of the following values:
78.Pp
79.Bl -tag -width Ds -offset indent -compact
80.It 0
81Each
82.Ar directory
83argument referred to an empty directory and was removed successfully.
84.It \*(Gt0
85An error occurred.
86.El
87.Sh EXAMPLES
88Remove the directory
89.Pa foobar ,
90if it is empty:
91.Pp
92.Dl $ rmdir foobar
93.Pp
94Remove all directories up to and including
95.Pa cow ,
96stopping at the first non-empty directory (if any):
97.Pp
98.Dl $ rmdir -p cow/horse/monkey
99.Sh SEE ALSO
100.Xr rm 1 ,
101.Xr rmdir 2
102.Sh STANDARDS
103The
104.Nm
105utility is compliant with the
106.St -p1003.1-2008
107specification.
108.Sh HISTORY
109A
110.Nm
111command appeared in
112.At v1 .
113