4815 Want rm support for -v option
4816 rm does not print error messages when -f is used

   1 '\" te
   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 "Nov 20, 2007"
  14 .SH NAME
  15 rm, rmdir \- remove directory entries
  16 .SH SYNOPSIS
  17 .LP
  18 .nf
  19 \fB/usr/bin/rm\fR [\fB-f\fR] [\fB-i\fR] \fIfile\fR...
  20 .fi
  21 
  22 .LP
  23 .nf
  24 \fB/usr/bin/rm\fR \fB-rR\fR [\fB-f\fR] [\fB-i\fR] \fIdirname\fR... [\fIfile\fR]...
  25 .fi
  26 
  27 .LP
  28 .nf
  29 \fB/usr/xpg4/bin/rm\fR [\fB-fiRr\fR] \fIfile\fR...
  30 .fi
  31 
  32 .LP
  33 .nf
  34 \fB/usr/bin/rmdir\fR [\fB-ps\fR] \fIdirname\fR...
  35 .fi
  36 
  37 .SS "ksh93"
  38 .LP
  39 .nf
  40 \fB/usr/bin/rmdir\fR [\fB-eps\fR] \fIdirname\fR...
  41 .fi
  42 
  43 .SH DESCRIPTION
  44 .SS "/usr/bin/rm /usr/xpg4/bin/rm"
  45 .sp
  46 .LP
  47 The \fBrm\fR utility removes the directory entry specified by each \fIfile\fR
  48 argument. If a file has no write permission and the standard input is a
  49 terminal, the full set of permissions (in octal) for the file are printed
  50 followed by a question mark. This is a prompt for confirmation. If the answer
  51 is affirmative, the file is deleted, otherwise the file remains.
  52 .sp
  53 .LP
  54 If \fIfile\fR is a symbolic link, the link is removed, but the file or
  55 directory to which it refers is not deleted. Users do not need write permission
  56 to remove a symbolic link, provided they have write permissions in the
  57 directory.
  58 .sp
  59 .LP
  60 If multiple \fIfile\fRs are specified and removal of a \fIfile\fR fails for any
  61 reason, \fBrm\fR writes a diagnostic message to standard error, do nothing more
  62 to the current \fIfile\fR, and go on to any remaining \fIfile\fRs.
  63 .sp
  64 .LP
  65 If the standard input is not a terminal, the utility operates as if the
  66 \fB-f\fR option is in effect.
  67 .SS "/usr/bin/rmdir"
  68 .sp
  69 .LP
  70 The \fBrmdir\fR utility removes the directory entry specified by each
  71 \fIdirname\fR operand, which must refer to an empty directory.
  72 .sp
  73 .LP
  74 Directories are processed in the order specified. If a directory and a
  75 subdirectory of that directory are specified in a single invocation of
  76 \fBrmdir\fR, the subdirectory must be specified before the parent directory so
  77 that the parent directory is empty when \fBrmdir\fR tries to remove it.
  78 .SS "ksh93"
  79 .sp
  80 .LP
  81 The \fBrmdir\fR built-in in \fBksh93\fR is associated with the \fB/bin\fR and
  82 \fB/usr/bin\fR paths. It is invoked when \fBrmdir\fR is executed without a
  83 pathname prefix and the pathname search finds a \fB/bin/rmdir\fR or
  84 \fB/usr/bin/rmdir\fR executable.
  85 .sp
  86 .LP
  87 \fBrmdir\fR deletes each given directory. The directory must be empty and
  88 contain no entries other than \fB\&.\fR or \fB\&..\fR. If a directory and a
  89 subdirectory of that directory are specified as operands, the subdirectory must
  90 be specified before the parent, so that the parent directory is empty when
  91 \fBrmdir\fR attempts to remove it.
  92 .SH OPTIONS
  93 .sp
  94 .LP
  95 The following options are supported for \fB/usr/bin/rm\fR and
  96 \fB/usr/xpg4/bin/rm\fR:
  97 .sp
  98 .ne 2
  99 .na
 100 \fB\fB-r\fR\fR
 101 .ad
 102 .RS 6n
 103 Recursively removes directories and subdirectories in the argument list. The
 104 directory is emptied of files and removed. The user is normally prompted for
 105 removal of any write-protected files which the directory contains. The
 106 write-protected files are removed without prompting, however, if the \fB-f\fR
 107 option is used, or if the standard input is not a terminal and the \fB-i\fR
 108 option is not used.
 109 .sp
 110 Symbolic links that are encountered with this option is not traversed.
 111 .sp
 112 If the removal of a non-empty, write-protected directory is attempted, the
 113 utility always fails (even if the \fB-f\fR option is used), resulting in an
 114 error message.
 115 .RE
 116 
 117 .sp
 118 .ne 2
 119 .na
 120 \fB\fB-R\fR\fR
 121 .ad
 122 .RS 6n
 123 Same as \fB-r\fR option.
 124 .RE
 125 
 126 .SS "/usr/bin/rm"
 127 .sp
 128 .LP
 129 The following options are supported for \fB/usr/bin/rm\fR only:
 130 .sp
 131 .ne 2
 132 .na
 133 \fB\fB-f\fR\fR
 134 .ad
 135 .RS 6n
 136 Removes all files (whether write-protected or not) in a directory without
 137 prompting the user. In a write-protected directory, however, files are never
 138 removed (whatever their permissions are), but no messages are displayed. If the
 139 removal of a write-protected directory is attempted, this option does not
 140 suppress an error message.
 141 .RE
 142 
 143 .sp
 144 .ne 2
 145 .na
 146 \fB\fB-i\fR\fR
 147 .ad
 148 .RS 6n
 149 Interactive. With this option, \fBrm\fR prompts for confirmation before
 150 removing any files. It overrides the \fB-f\fR option and remains in effect even
 151 if the standard input is not a terminal.
 152 .RE
 153 
 154 .SS "/usr/xpg4/bin/rm"
 155 .sp
 156 .LP
 157 The following options are supported for \fB/usr/xpg4/bin/rm\fR only:
 158 .sp
 159 .ne 2
 160 .na
 161 \fB\fB-f\fR\fR
 162 .ad
 163 .RS 6n
 164 Does not prompt for confirmation. Does not write diagnostic messages or modify
 165 the exit status in the case of non-existent operands. Any previous occurrences
 166 of the \fB-i\fR option is ignored.
 167 .RE
 168 
 169 .sp
 170 .ne 2
 171 .na
 172 \fB\fB-i\fR\fR
 173 .ad
 174 .RS 6n
 175 Prompts for confirmation. Any occurrences of the \fB-f\fR option is ignored.


 176 .RE
 177 
 178 .SS "/usr/bin/rmdir"
 179 .sp
 180 .LP
 181 The following options are supported for \fB/usr/bin/rmdir\fR only:
 182 .sp
 183 .ne 2
 184 .na
 185 \fB\fB-p\fR\fR
 186 .ad
 187 .RS 6n
 188 Allows users to remove the directory \fIdirname\fR and its parent directories
 189 which become empty. A message is printed to standard error if all or part of
 190 the path could not be removed.
 191 .RE
 192 
 193 .sp
 194 .ne 2
 195 .na
 196 \fB\fB-s\fR\fR
 197 .ad
 198 .RS 6n
 199 Suppresses the message printed on the standard error when \fB-p\fR is in
 200 effect.
 201 .RE
 202 
 203 .SS "ksh93"
 204 .sp
 205 .LP
 206 The following options are supported for the \fBrmdir\fR built-in for
 207 \fBksh93\fR:
 208 .sp
 209 .ne 2
 210 .na
 211 \fB\fB-e\fR\fR
 212 .ad
 213 .br
 214 .na
 215 \fB\fB--ignore-fail-on-non-empty\fR\fR
 216 .ad
 217 .RS 30n
 218 Ignore each non-empty directory failure.
 219 .RE
 220 
 221 .sp
 222 .ne 2
 223 .na
 224 \fB\fB-p\fR\fR
 225 .ad
 226 .br
 227 .na
 228 \fB\fB--parents\fR\fR
 229 .ad
 230 .RS 30n
 231 Remove each explicit directory argument directory that becomes empty after its
 232 child directories are removed.
 233 .RE
 234 
 235 .sp
 236 .ne 2
 237 .na
 238 \fB\fB-s\fR\fR
 239 .ad
 240 .br
 241 .na
 242 \fB\fB--suppress\fR\fR
 243 .ad
 244 .RS 30n
 245 Suppress the message printed on the standard error when \fB-p\fR is in effect.
 246 .RE
 247 
 248 .SH OPERANDS
 249 .sp
 250 .LP
 251 The following operands are supported:
 252 .sp
 253 .ne 2
 254 .na
 255 \fB\fIfile\fR\fR
 256 .ad
 257 .RS 11n
 258 Specifies the pathname of a directory entry to be removed.
 259 .RE
 260 
 261 .sp
 262 .ne 2
 263 .na
 264 \fB\fIdirname\fR\fR
 265 .ad
 266 .RS 11n
 267 Specifies the pathname of an empty directory to be removed.
 268 .RE
 269 
 270 .SH USAGE
 271 .sp
 272 .LP
 273 See \fBlargefile\fR(5) for the description of the behavior of \fBrm\fR and
 274 \fBrmdir\fR when encountering files greater than or equal to 2 Gbyte ( 2^31
 275 bytes).
 276 .SH EXAMPLES
 277 .sp
 278 .LP
 279 The following examples are valid for the commands shown.
 280 .SS "/usr/bin/rm, /usr/xpg4/bin/rm"
 281 .LP
 282 \fBExample 1 \fRRemoving Directories
 283 .sp
 284 .LP
 285 The following command removes the directory entries \fBa.out\fR and \fBcore\fR:
 286 
 287 .sp
 288 .in +2
 289 .nf
 290 example% \fBrm a.out core\fR
 291 .fi
 292 .in -2
 293 .sp
 294 
 295 .LP
 296 \fBExample 2 \fRRemoving a Directory without Prompting
 297 .sp
 298 .LP
 299 The following command removes the directory \fBjunk\fR and all its contents,
 300 without prompting:
 301 
 302 .sp
 303 .in +2
 304 .nf
 305 example% \fBrm -rf junk\fR
 306 .fi
 307 .in -2
 308 .sp
 309 
 310 .SS "/usr/bin/rmdir"
 311 .LP
 312 \fBExample 3 \fRRemoving Empty Directories
 313 .sp
 314 .LP
 315 If a directory \fBa\fR in the current directory is empty, except that it
 316 contains a directory \fBb\fR, and \fBa/b\fR is empty except that it contains a
 317 directory \fBc\fR, the following command removes all three directories:
 318 
 319 .sp
 320 .in +2
 321 .nf
 322 example% \fBrmdir -p a/b/c\fR
 323 .fi
 324 .in -2
 325 .sp
 326 
 327 .SH ENVIRONMENT VARIABLES
 328 .sp
 329 .LP
 330 See \fBenviron\fR(5) for descriptions of the following environment variables
 331 that affect the execution of \fBrm\fR and \fBrmdir\fR: \fBLANG\fR,
 332 \fBLC_ALL\fR, \fBLC_COLLATE\fR, \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and
 333 \fBNLSPATH\fR.
 334 .sp
 335 .LP
 336 Affirmative responses are processed using the extended regular expression
 337 defined for the \fByesexpr\fR keyword in the \fBLC_MESSAGES\fR category of the
 338 user's locale. The locale specified in the \fBLC_COLLATE\fR category defines
 339 the behavior of ranges, equivalence classes, and multi-character collating
 340 elements used in the expression defined for \fByesexpr\fR. The locale specified
 341 in \fBLC_CTYPE\fR determines the locale for interpretation of sequences of
 342 bytes of text data a characters, the behavior of character classes used in the
 343 expression defined for the \fByesexpr\fR. See \fBlocale\fR(5).
 344 .SH EXIT STATUS
 345 .sp
 346 .LP
 347 The following exit values are returned:
 348 .sp
 349 .ne 2
 350 .na
 351 \fB\fB0\fR\fR
 352 .ad
 353 .RS 6n
 354 If the \fB-f\fR option was not specified, all the named directory entries were
 355 removed; otherwise, all the existing named directory entries were removed.
 356 .RE
 357 
 358 .sp
 359 .ne 2
 360 .na
 361 \fB\fB>0\fR\fR
 362 .ad
 363 .RS 6n
 364 An error occurred.
 365 .RE
 366 
 367 .SS "ksh93"
 368 .sp
 369 .LP
 370 The following exit values are returned:
 371 .sp
 372 .ne 2
 373 .na
 374 \fB\fB0\fR\fR
 375 .ad
 376 .RS 6n
 377 Successful completion. All directories deleted successfully.
 378 .RE
 379 
 380 .sp
 381 .ne 2
 382 .na
 383 \fB\fB>0\fR\fR
 384 .ad
 385 .RS 6n
 386 An error occurred. One or more directories could not be deleted.
 387 .RE
 388 
 389 .SH ATTRIBUTES
 390 .sp
 391 .LP
 392 See \fBattributes\fR(5) for descriptions of the following attributes:
 393 .SS "/usr/bin/rm, /usr/bin/rmdir"
 394 .sp
 395 
 396 .sp
 397 .TS
 398 box;
 399 c | c
 400 l | l .
 401 ATTRIBUTE TYPE  ATTRIBUTE VALUE
 402 _
 403 CSI     Enabled
 404 .TE
 405 
 406 .SS "/usr/xpg4/bin/rm"
 407 .sp
 408 
 409 .sp
 410 .TS
 411 box;
 412 c | c
 413 l | l .
 414 ATTRIBUTE TYPE  ATTRIBUTE VALUE
 415 _
 416 CSI     Enabled
 417 _
 418 Interface Stability     Committed
 419 _
 420 Standard        See \fBstandards\fR(5).
 421 .TE
 422 
 423 .SS "ksh93"
 424 .sp
 425 
 426 .sp
 427 .TS
 428 box;
 429 c | c
 430 l | l .
 431 ATTRIBUTE TYPE  ATTRIBUTE VALUE
 432 _
 433 Interface Stability     See below.
 434 .TE
 435 
 436 .sp
 437 .LP
 438 The \fBksh93\fR built-in binding to \fB/bin\fR and \fB/usr/bin\fR is Volatile.
 439 The built-in interfaces are Uncommitted.
 440 .SH SEE ALSO
 441 .sp
 442 .LP
 443 \fBksh93\fR(1), \fBrmdir\fR(2), \fBrmdir\fR(2), \fBunlink\fR(2),
 444 \fBattributes\fR(5), \fBenviron\fR(5), \fBlargefile\fR(5), \fBstandards\fR(5)
 445 .SH DIAGNOSTICS
 446 .sp
 447 .LP
 448 All messages are generally self-explanatory.
 449 .sp
 450 .LP
 451 It is forbidden to remove the files "\fB\&.\fR" and "\fB\&..\fR" in order to
 452 avoid the consequences of inadvertently doing something like the following:
 453 .sp
 454 .in +2
 455 .nf
 456 example% \fBrm -r .*\fR
 457 .fi
 458 .in -2
 459 .sp
 460 
 461 .sp
 462 .LP
 463 It is forbidden to remove the file "\fB/\fR" in order to avoid the consequences
 464 of inadvertently doing something like:
 465 .sp
 466 .in +2
 467 .nf
 468 example% \fBrm -rf $x/$y\fR
 469 .fi
 470 .in -2
 471 .sp
 472 
 473 .sp
 474 .LP
 475 or
 476 .sp
 477 .in +2
 478 .nf
 479 example% \fBrm -rf /$y\fR
 480 .fi
 481 .in -2
 482 .sp
 483 
 484 .sp
 485 .LP
 486 when \fB$x\fR and \fB$y\fR expand to empty strings.
 487 .SH NOTES
 488 .sp
 489 .LP
 490 A \fB\(mi\fR permits the user to mark explicitly the end of any command line
 491 options, allowing \fBrm\fR to recognize file arguments that begin with a
 492 \fB\(mi\fR\&. As an aid to BSD migration, \fBrm\fR accepts \fB\(mi\|\(mi\fR as
 493 a synonym for \fB\(mi\fR\&. This migration aid may disappear in a future
 494 release. If a \fB\(mi\|\(mi\fR and a \fB\(mi\fR both appear on the same command
 495 line, the second is interpreted as a file.
--- EOF ---