1c10c16deSRichard Lowe'\" te 2c10c16deSRichard Lowe.\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved 3c10c16deSRichard Lowe.\" Copyright 1989 AT&T 4c10c16deSRichard Lowe.\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures 5c10c16deSRichard Lowe.\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved 6c10c16deSRichard Lowe.\" 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 7c10c16deSRichard Lowe.\" http://www.opengroup.org/bookstore/. 8c10c16deSRichard Lowe.\" 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*a48ca82fSJason King.\" Copyright 2017 Joyent, Inc. 10c10c16deSRichard Lowe.\" This notice shall appear on any product containing this material. 11c10c16deSRichard Lowe.\" 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. 12c10c16deSRichard Lowe.\" 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. 13c10c16deSRichard Lowe.\" 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] 14*a48ca82fSJason King.Dd July 3, 2017 15*a48ca82fSJason King.Dt RM 1 16*a48ca82fSJason King.Os 17*a48ca82fSJason King.Sh NAME 18*a48ca82fSJason King.Nm rm , 19*a48ca82fSJason King.Nm rmdir 20*a48ca82fSJason King.Nd remove directory entries 21*a48ca82fSJason King.Sh SYNOPSIS 22*a48ca82fSJason King.Nm /usr/bin/rm 23*a48ca82fSJason King.Op Fl f 24*a48ca82fSJason King.Op Fl i 25*a48ca82fSJason King.Ar 26*a48ca82fSJason King.Pp 27*a48ca82fSJason King.Nm /usr/bin/rm 28*a48ca82fSJason King.Fl rR 29*a48ca82fSJason King.Op Fl f 30*a48ca82fSJason King.Op Fl i 31*a48ca82fSJason King.Ar dirname ... 32*a48ca82fSJason King.Op Ar file ... 33*a48ca82fSJason King.Pp 34*a48ca82fSJason King.Nm /usr/xpg4/bin/rm 35*a48ca82fSJason King.Op Fl fiRr 36*a48ca82fSJason King.Ar 37*a48ca82fSJason King.Pp 38*a48ca82fSJason King.Nm /usr/bin/rmdir 39*a48ca82fSJason King.Op Fl ps 40*a48ca82fSJason King.Ar dirname 41*a48ca82fSJason King.Ss "ksh93" 42*a48ca82fSJason King.Nm /usr/bin/rmdir 43*a48ca82fSJason King.Op Fl eps 44*a48ca82fSJason King.Ar dirname ... 45*a48ca82fSJason King.Sh DESCRIPTION 46*a48ca82fSJason King.Ss "/usr/bin/rm /usr/xpg4/bin/rm" 47*a48ca82fSJason KingThe 48*a48ca82fSJason King.Nm rm 49*a48ca82fSJason Kingutility removes the directory entry specified by each 50*a48ca82fSJason King.Ar file 51*a48ca82fSJason Kingargument. 52*a48ca82fSJason KingIf a file has no write permission and the standard input is a terminal, the 53*a48ca82fSJason Kingfull set of permissions (in octal) for the file are printed followed by a 54*a48ca82fSJason Kingquestion mark. 55*a48ca82fSJason KingThis is a prompt for confirmation. 56*a48ca82fSJason KingIf the answer is affirmative, the file is deleted, otherwise the file remains. 57*a48ca82fSJason King.Pp 58*a48ca82fSJason KingIf 59*a48ca82fSJason King.Ar file 60*a48ca82fSJason Kingis a symbolic link, the link is removed, but the file or directory to which it 61*a48ca82fSJason Kingrefers is not deleted. 62*a48ca82fSJason KingUsers do not need write permission to remove a symbolic link, provided they 63*a48ca82fSJason Kinghave write permissions in the directory. 64*a48ca82fSJason King.Pp 65*a48ca82fSJason KingIf multiple 66*a48ca82fSJason King.Ar file Ns s 67*a48ca82fSJason Kingare specified and removal of a 68*a48ca82fSJason King.Ar file 69*a48ca82fSJason Kingfails for any reason, 70*a48ca82fSJason King.Nm rm 71*a48ca82fSJason Kingwrites a diagnostic message to standard error, do nothing more to the current 72*a48ca82fSJason King.Ar file , 73*a48ca82fSJason Kingand go on to any remaining 74*a48ca82fSJason King.Ar file Ns s . 75*a48ca82fSJason King.Pp 76c10c16deSRichard LoweIf the standard input is not a terminal, the utility operates as if the 77*a48ca82fSJason King.Fl f 78*a48ca82fSJason Kingoption is in effect. 79*a48ca82fSJason King.Ss "/usr/bin/rmdir" 80*a48ca82fSJason KingThe 81*a48ca82fSJason King.Nm rmdir 82*a48ca82fSJason Kingutility removes the directory entry specified by each 83*a48ca82fSJason King.Ar dirname 84*a48ca82fSJason Kingoperand, which must refer to an empty directory. 85*a48ca82fSJason King.Pp 86*a48ca82fSJason KingDirectories are processed in the order specified. 87*a48ca82fSJason KingIf a directory and a subdirectory of that directory are specified in a single 88*a48ca82fSJason Kinginvocation of 89*a48ca82fSJason King.Nm rmdir , 90*a48ca82fSJason Kingthe subdirectory must be specified before the parent directory so that the 91*a48ca82fSJason Kingparent directory is empty when 92*a48ca82fSJason King.Nm rmdir 93*a48ca82fSJason Kingtries to remove it. 94*a48ca82fSJason King.Ss "ksh93" 95*a48ca82fSJason KingThe 96*a48ca82fSJason King.Nm rmdir 97*a48ca82fSJason Kingbuilt-in in 98*a48ca82fSJason King.Nm ksh93 99*a48ca82fSJason Kingis associated with the 100*a48ca82fSJason King.Pa /bin 101*a48ca82fSJason Kingand 102*a48ca82fSJason King.Pa /usr/bin 103*a48ca82fSJason Kingpaths. 104*a48ca82fSJason KingIt is invoked when 105*a48ca82fSJason King.Nm rmdir 106*a48ca82fSJason Kingis executed without a pathname prefix and the pathname search finds a 107*a48ca82fSJason King.Pa /bin/rmdir 108*a48ca82fSJason Kingor 109*a48ca82fSJason King.Pa /usr/bin/rmdir 110*a48ca82fSJason Kingexecutable. 111*a48ca82fSJason King.Pp 112*a48ca82fSJason King.Nm rmdir 113*a48ca82fSJason Kingdeletes each given directory. 114*a48ca82fSJason KingThe directory must be empty and contain no entries other than 115*a48ca82fSJason King.Pa \&. 116*a48ca82fSJason Kingor 117*a48ca82fSJason King.Pa .. . 118*a48ca82fSJason KingIf a directory and a 119c10c16deSRichard Lowesubdirectory of that directory are specified as operands, the subdirectory must 120c10c16deSRichard Lowebe specified before the parent, so that the parent directory is empty when 121*a48ca82fSJason King.Nm rmdir 122*a48ca82fSJason Kingattempts to remove it. 123*a48ca82fSJason King.Sh OPTIONS 124*a48ca82fSJason KingThe following options are supported for 125*a48ca82fSJason King.Nm /usr/bin/rm 126*a48ca82fSJason Kingand 127*a48ca82fSJason King.Nm /usr/xpg4/bin/rm : 128*a48ca82fSJason King.Bl -hang 129*a48ca82fSJason King.It Fl r 130*a48ca82fSJason KingRecursively removes directories and subdirectories in the argument list. 131*a48ca82fSJason KingThe directory is emptied of files and removed. 132*a48ca82fSJason KingThe user is normally prompted for removal of any write-protected files which 133*a48ca82fSJason Kingthe directory contains. 134*a48ca82fSJason KingThe write-protected files are removed without prompting, however, if the 135*a48ca82fSJason King.Fl f 136*a48ca82fSJason Kingoption is used, or if the standard input is not a terminal and the 137*a48ca82fSJason King.Fl i 138c10c16deSRichard Loweoption is not used. 139*a48ca82fSJason King.Pp 140c10c16deSRichard LoweSymbolic links that are encountered with this option is not traversed. 141*a48ca82fSJason King.Pp 142c10c16deSRichard LoweIf the removal of a non-empty, write-protected directory is attempted, the 143*a48ca82fSJason Kingutility always fails (even if the 144*a48ca82fSJason King.Fl f 145*a48ca82fSJason Kingoption is used), resulting in an error message. 146*a48ca82fSJason King.It Fl R 147*a48ca82fSJason KingSame as 148*a48ca82fSJason King.Fl r 149*a48ca82fSJason Kingoption. 150*a48ca82fSJason King.El 151*a48ca82fSJason King.Ss "/usr/bin/rm" 152*a48ca82fSJason KingThe following options are supported for 153*a48ca82fSJason King.Nm /usr/bin/rm 154*a48ca82fSJason Kingonly: 155*a48ca82fSJason King.Bl -hang 156*a48ca82fSJason King.It Fl f 157c10c16deSRichard LoweRemoves all files (whether write-protected or not) in a directory without 158*a48ca82fSJason Kingprompting the user. 159*a48ca82fSJason KingIn a write-protected directory, however, files are never removed (whatever 160*a48ca82fSJason Kingtheir permissions are), but no messages are displayed. 161*a48ca82fSJason KingIf the removal of a write-protected directory is attempted, this option does 162*a48ca82fSJason Kingnot suppress an error message. 163*a48ca82fSJason King.It Fl i 164*a48ca82fSJason KingInteractive. 165*a48ca82fSJason KingWith this option, 166*a48ca82fSJason King.Nm rm 167*a48ca82fSJason Kingprompts for confirmation before 168*a48ca82fSJason Kingremoving any files. 169*a48ca82fSJason KingIt overrides the 170*a48ca82fSJason King.Fl f 171*a48ca82fSJason Kingoption and remains in effect even if the standard input is not a terminal. 172*a48ca82fSJason King.El 173*a48ca82fSJason King.Ss "/usr/xpg4/bin/rm" 174*a48ca82fSJason KingThe following options are supported for 175*a48ca82fSJason King.Nm /usr/xpg4/bin/rm 176*a48ca82fSJason Kingonly: 177*a48ca82fSJason King.Bl -hang 178*a48ca82fSJason King.It Fl f 179*a48ca82fSJason KingDoes not prompt for confirmation. 180*a48ca82fSJason KingDoes not write diagnostic messages or modify the exit status in the case of 181*a48ca82fSJason Kingnon-existent operands. 182*a48ca82fSJason KingAny previous occurrences of the 183*a48ca82fSJason King.Fl i 184*a48ca82fSJason Kingoption is ignored. 185*a48ca82fSJason King.It Fl i 186*a48ca82fSJason KingPrompts for confirmation. 187*a48ca82fSJason KingAny occurrences of the 188*a48ca82fSJason King.Fl f 189*a48ca82fSJason Kingoption is ignored. 190*a48ca82fSJason King.El 191*a48ca82fSJason King.Ss "/usr/bin/rmdir" 192*a48ca82fSJason KingThe following options are supported for 193*a48ca82fSJason King.Nm /usr/bin/rmdir 194*a48ca82fSJason Kingonly: 195*a48ca82fSJason King.Bl -hang 196*a48ca82fSJason King.It Fl p 197*a48ca82fSJason KingAllows users to remove the directory 198*a48ca82fSJason King.Ar dirname 199*a48ca82fSJason Kingand its parent directories which become empty. 200*a48ca82fSJason KingA message is printed to standard error if all or part of the path could not be 201*a48ca82fSJason Kingremoved. 202*a48ca82fSJason King.It Fl s 203*a48ca82fSJason KingSuppresses the message printed on the standard error when 204*a48ca82fSJason King.Fl p 205*a48ca82fSJason Kingis in effect. 206*a48ca82fSJason King.El 207*a48ca82fSJason King.Ss "ksh93" 208*a48ca82fSJason KingThe following options are supported for the 209*a48ca82fSJason King.Nm rmdir 210*a48ca82fSJason Kingbuilt-in for 211*a48ca82fSJason King.Nm ksh93 : 212*a48ca82fSJason King.Pp 213*a48ca82fSJason King.Bl -hang -compact 214*a48ca82fSJason King.It Fl e 215*a48ca82fSJason King.It Fl -ignore-fail-on-non-empty 216c10c16deSRichard LoweIgnore each non-empty directory failure. 217*a48ca82fSJason King.El 218*a48ca82fSJason King.Pp 219*a48ca82fSJason King.Bl -hang -compact 220*a48ca82fSJason King.It Fl p 221*a48ca82fSJason King.It Fl -parents 222c10c16deSRichard LoweRemove each explicit directory argument directory that becomes empty after its 223c10c16deSRichard Lowechild directories are removed. 224*a48ca82fSJason King.El 225*a48ca82fSJason King.Pp 226*a48ca82fSJason King.Bl -hang -compact 227*a48ca82fSJason King.It Fl s 228*a48ca82fSJason King.It Fl -suppress 229*a48ca82fSJason KingSuppress the message printed on the standard error when 230*a48ca82fSJason King.Fl p 231*a48ca82fSJason Kingis in effect. 232*a48ca82fSJason King.El 233*a48ca82fSJason King.Sh OPERANDS 234c10c16deSRichard LoweThe following operands are supported: 235*a48ca82fSJason King.Bl -tag -width Ar 236*a48ca82fSJason King.It Ar file 237c10c16deSRichard LoweSpecifies the pathname of a directory entry to be removed. 238*a48ca82fSJason King.It Ar dirname 239c10c16deSRichard LoweSpecifies the pathname of an empty directory to be removed. 240*a48ca82fSJason King.El 241*a48ca82fSJason King.Sh USAGE 242*a48ca82fSJason KingSee 243*a48ca82fSJason King.Xr largefile 5 244*a48ca82fSJason Kingfor the description of the behavior of 245*a48ca82fSJason King.Nm rm 246*a48ca82fSJason Kingand 247*a48ca82fSJason King.Nm rmdir 248*a48ca82fSJason Kingwhen encountering files greater than or equal to 2 Gbyte (2^31 bytes). 249*a48ca82fSJason King.Sh EXIT STATUS 250c10c16deSRichard LoweThe following exit values are returned: 251*a48ca82fSJason King.Bl -tag -width Sy 252*a48ca82fSJason King.It Sy 0 253*a48ca82fSJason KingIf the 254*a48ca82fSJason King.Fl f 255*a48ca82fSJason Kingoption was not specified, all the named directory entries were 256c10c16deSRichard Loweremoved; otherwise, all the existing named directory entries were removed. 257*a48ca82fSJason King.It Sy >0 258c10c16deSRichard LoweAn error occurred. 259*a48ca82fSJason King.El 260*a48ca82fSJason King.Ss "ksh93" 261c10c16deSRichard LoweThe following exit values are returned: 262*a48ca82fSJason King.Bl -tag -width Sy 263*a48ca82fSJason King.It Sy 0 264*a48ca82fSJason KingSuccessful completion. 265*a48ca82fSJason KingAll directories deleted successfully. 266*a48ca82fSJason King.It Sy >0 267*a48ca82fSJason KingAn error occurred. 268*a48ca82fSJason KingOne or more directories could not be deleted. 269*a48ca82fSJason King.El 270*a48ca82fSJason King.Sh EXAMPLES 271*a48ca82fSJason KingThe following examples are valid for the commands shown. 272*a48ca82fSJason King.Ss "/usr/bin/rm, /usr/xpg4/bin/rm" 273*a48ca82fSJason King.Bl -ohang 274*a48ca82fSJason King.It Sy Example 1 No Removing Directories 275*a48ca82fSJason King.Pp 276*a48ca82fSJason KingThe following command removes the directory entries 277*a48ca82fSJason King.Pa a.out 278*a48ca82fSJason Kingand 279*a48ca82fSJason King.Pa core : 280*a48ca82fSJason King.Pp 281*a48ca82fSJason King.Dl example% rm a.out core 282*a48ca82fSJason King.El 283*a48ca82fSJason King.Bl -ohang 284*a48ca82fSJason King.It Sy Example 2 No Removing a Directory without Prompting 285*a48ca82fSJason King.Pp 286*a48ca82fSJason KingThe following command removes the directory 287*a48ca82fSJason King.Pa junk 288*a48ca82fSJason Kingand all its contents, without prompting: 289*a48ca82fSJason King.Pp 290*a48ca82fSJason King.Dl example% rm -rf junk 291*a48ca82fSJason King.El 292*a48ca82fSJason King.Ss "/usr/bin/rmdir" 293*a48ca82fSJason King.Bl -ohang 294*a48ca82fSJason King.It Sy Example 3 No Removing Empty Directories 295*a48ca82fSJason King.Pp 296*a48ca82fSJason KingIf a directory 297*a48ca82fSJason King.Pa a 298*a48ca82fSJason Kingin the current directory is empty, except that it contains a directory 299*a48ca82fSJason King.Pa b , 300*a48ca82fSJason Kingand 301*a48ca82fSJason King.Pa a/b 302*a48ca82fSJason Kingis empty except that it contains a directory 303*a48ca82fSJason King.Pa c , 304*a48ca82fSJason Kingthe following command removes all three directories: 305*a48ca82fSJason King.Pp 306*a48ca82fSJason King.Dl example% rmdir -p a/b/c 307*a48ca82fSJason King.El 308*a48ca82fSJason King.Sh DIAGNOSTICS 309c10c16deSRichard LoweAll messages are generally self-explanatory. 310*a48ca82fSJason King.Pp 311*a48ca82fSJason KingIt is forbidden to remove the files 312*a48ca82fSJason King.Qq Pa \&. 313*a48ca82fSJason Kingand 314*a48ca82fSJason King.Qq Pa .. 315*a48ca82fSJason Kingin order to 316c10c16deSRichard Loweavoid the consequences of inadvertently doing something like the following: 317*a48ca82fSJason King.Pp 318*a48ca82fSJason King.Dl example% rm -r .* 319*a48ca82fSJason King.Pp 320*a48ca82fSJason KingIt is forbidden to remove the file 321*a48ca82fSJason King.Qq Pa / 322*a48ca82fSJason Kingin order to avoid the consequences of inadvertently doing something like: 323*a48ca82fSJason King.Pp 324*a48ca82fSJason King.Dl example% rm -rf $x/$y 325*a48ca82fSJason King.Pp 326c10c16deSRichard Loweor 327*a48ca82fSJason King.Pp 328*a48ca82fSJason King.Dl example% rm -rf /$y 329*a48ca82fSJason King.Pp 330*a48ca82fSJason Kingwhen 331*a48ca82fSJason King.Va $x 332*a48ca82fSJason Kingand 333*a48ca82fSJason King.Va $y 334*a48ca82fSJason Kingexpand to empty strings. 335*a48ca82fSJason King.Sh ENVIRONMENT VARIABLES 336*a48ca82fSJason KingSee 337*a48ca82fSJason King.Xr environ 5 338*a48ca82fSJason Kingfor descriptions of the following environment variables that affect the 339*a48ca82fSJason Kingexecution of 340*a48ca82fSJason King.Nm rm 341*a48ca82fSJason Kingand 342*a48ca82fSJason King.Nm rmdir : 343*a48ca82fSJason King.Ev LANG , 344*a48ca82fSJason King.Ev LC_ALL , 345*a48ca82fSJason King.Ev LC_COLLATE , 346*a48ca82fSJason King.Ev LC_CTYPE , 347*a48ca82fSJason King.Ev LC_MESSAGES , 348*a48ca82fSJason Kingand 349*a48ca82fSJason King.Ev NLSPATH . 350*a48ca82fSJason King.Pp 351*a48ca82fSJason KingAffirmative responses are processed using the extended regular expression 352*a48ca82fSJason Kingdefined for the 353*a48ca82fSJason King.Sy yesexpr 354*a48ca82fSJason Kingkeyword in the 355*a48ca82fSJason King.Ev LC_MESSAGES 356*a48ca82fSJason Kingcategory of the 357*a48ca82fSJason Kinguser's locale. 358*a48ca82fSJason KingThe locale specified in the 359*a48ca82fSJason King.Ev LC_COLLATE 360*a48ca82fSJason Kingcategory defines 361*a48ca82fSJason Kingthe behavior of ranges, equivalence classes, and multi-character collating 362*a48ca82fSJason Kingelements used in the expression defined for 363*a48ca82fSJason King.Sy yesexpr . 364*a48ca82fSJason KingThe locale specified in 365*a48ca82fSJason King.Ev LC_CTYPE 366*a48ca82fSJason Kingdetermines the locale for interpretation of sequences of 367*a48ca82fSJason Kingbytes of text data a characters, the behavior of character classes used in the 368*a48ca82fSJason Kingexpression defined for the 369*a48ca82fSJason King.Sy yesexpr . 370*a48ca82fSJason KingSee 371*a48ca82fSJason King.Xr locale 5 . 372*a48ca82fSJason King.Sh INTERFACE STABILITY 373*a48ca82fSJason King.Ss "/usr/xpg4/bin/rm" 374*a48ca82fSJason KingCommitted 375*a48ca82fSJason King.Ss "ksh93" 376*a48ca82fSJason KingThe 377*a48ca82fSJason King.Nm ksh93 378*a48ca82fSJason Kingbuilt-in binding to 379*a48ca82fSJason King.Pa /bin 380*a48ca82fSJason Kingand 381*a48ca82fSJason King.Pa /usr/bin 382*a48ca82fSJason Kingis Volatile. 383*a48ca82fSJason KingThe built-in interfaces are Uncommitted. 384*a48ca82fSJason King.Sh SEE ALSO 385*a48ca82fSJason King.Xr ksh93 1 , 386*a48ca82fSJason King.Xr rmdir 2 , 387*a48ca82fSJason King.Xr rmdir 2 , 388*a48ca82fSJason King.Xr unlink 2 , 389*a48ca82fSJason King.Xr attributes 5 , 390*a48ca82fSJason King.Xr environ 5 , 391*a48ca82fSJason King.Xr largefile 5 , 392*a48ca82fSJason King.Xr standards 5 393*a48ca82fSJason King.Sh NOTES 394*a48ca82fSJason KingA 395*a48ca82fSJason King.Fl 396*a48ca82fSJason Kingpermits the user to mark explicitly the end of any command line options, 397*a48ca82fSJason Kingallowing 398*a48ca82fSJason King.Nm rm 399*a48ca82fSJason Kingto recognize file arguments that begin with a 400*a48ca82fSJason King.Fl . 401*a48ca82fSJason KingAs an aid to BSD migration, 402*a48ca82fSJason King.Nm rm 403*a48ca82fSJason Kingaccepts 404*a48ca82fSJason King.Fl - 405*a48ca82fSJason Kingas a synonym for 406*a48ca82fSJason King.Fl . 407*a48ca82fSJason KingThis migration aid may disappear in a future release. 408*a48ca82fSJason KingIf a 409*a48ca82fSJason King.Fl - 410*a48ca82fSJason Kingand a 411*a48ca82fSJason King.Fl 412*a48ca82fSJason Kingboth appear on the same command line, the second is interpreted as a file. 413