1.\" $OpenBSD: rmdir.1,v 1.19 2009/02/08 17:15:09 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: February 8 2009 $ 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.Pp 75The 76.Nm 77utility exits with one of the following values: 78.Bl -tag -width Ds 79.It Li \&0 80Each 81.Ar directory 82argument referred to an empty directory and was removed successfully. 83.It Li \&>\&0 84An error occurred. 85.El 86.Sh EXAMPLES 87.Li $ rmdir foobar 88.Pp 89Remove the directory 90.Pa foobar 91if it is empty. 92.Pp 93.Li $ rmdir -p cow/horse/monkey 94.Pp 95Remove all directories up to and including 96.Pa cow , 97stopping at the first non-empty directory (if any). 98.Sh SEE ALSO 99.Xr rm 1 , 100.Xr rmdir 2 101.Sh STANDARDS 102The 103.Nm 104utility is compliant with the 105.St -p1003.1-2008 106specification. 107.Sh HISTORY 108A 109.Nm 110command appeared in 111.At v1 . 112