Print this page
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


  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


 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:


 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


   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 .\" Copyright 2014 Andrew Stormont.
   7 .\" 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
   8 .\" http://www.opengroup.org/bookstore/.
   9 .\" 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.
  10 .\"  This notice shall appear on any product containing this material.
  11 .\" 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.
  12 .\" 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.
  13 .\" 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 .TH RM 1 "Apr 30, 2014"
  15 .SH NAME
  16 rm, rmdir \- remove directory entries
  17 .SH SYNOPSIS
  18 .LP
  19 .nf
  20 \fB/usr/bin/rm\fR [\fB-f\fR] [\fB-i\fR] [\fB-v\fR] \fIfile\fR...
  21 .fi
  22 
  23 .LP
  24 .nf
  25 \fB/usr/bin/rm\fR \fB-rR\fR [\fB-f\fR] [\fB-i\fR] [\fB-v\fR] \fIdirname\fR... [\fIfile\fR]...





  26 .fi
  27 
  28 .LP
  29 .nf
  30 \fB/usr/bin/rmdir\fR [\fB-ps\fR] \fIdirname\fR...
  31 .fi
  32 
  33 .SS "ksh93"
  34 .LP
  35 .nf
  36 \fB/usr/bin/rmdir\fR [\fB-eps\fR] \fIdirname\fR...
  37 .fi
  38 
  39 .SH DESCRIPTION
  40 .SS "/usr/bin/rm"
  41 .sp
  42 .LP
  43 The \fBrm\fR utility removes the directory entry specified by each \fIfile\fR
  44 argument. If a file has no write permission and the standard input is a
  45 terminal, the full set of permissions (in octal) for the file are printed
  46 followed by a question mark. This is a prompt for confirmation. If the answer
  47 is affirmative, the file is deleted, otherwise the file remains.
  48 .sp
  49 .LP
  50 If \fIfile\fR is a symbolic link, the link is removed, but the file or
  51 directory to which it refers is not deleted. Users do not need write permission
  52 to remove a symbolic link, provided they have write permissions in the
  53 directory.
  54 .sp
  55 .LP
  56 If multiple \fIfile\fRs are specified and removal of a \fIfile\fR fails for any
  57 reason, \fBrm\fR writes a diagnostic message to standard error, do nothing more
  58 to the current \fIfile\fR, and go on to any remaining \fIfile\fRs.
  59 .sp
  60 .LP


  71 subdirectory of that directory are specified in a single invocation of
  72 \fBrmdir\fR, the subdirectory must be specified before the parent directory so
  73 that the parent directory is empty when \fBrmdir\fR tries to remove it.
  74 .SS "ksh93"
  75 .sp
  76 .LP
  77 The \fBrmdir\fR built-in in \fBksh93\fR is associated with the \fB/bin\fR and
  78 \fB/usr/bin\fR paths. It is invoked when \fBrmdir\fR is executed without a
  79 pathname prefix and the pathname search finds a \fB/bin/rmdir\fR or
  80 \fB/usr/bin/rmdir\fR executable.
  81 .sp
  82 .LP
  83 \fBrmdir\fR deletes each given directory. The directory must be empty and
  84 contain no entries other than \fB\&.\fR or \fB\&..\fR. If a directory and a
  85 subdirectory of that directory are specified as operands, the subdirectory must
  86 be specified before the parent, so that the parent directory is empty when
  87 \fBrmdir\fR attempts to remove it.
  88 .SH OPTIONS
  89 .sp
  90 .LP
  91 The following options are supported for \fB/usr/bin/rm\fR only:

  92 .sp
  93 .ne 2
  94 .na
  95 \fB\fB-r\fR\fR
  96 .ad
  97 .RS 6n
  98 Recursively removes directories and subdirectories in the argument list. The
  99 directory is emptied of files and removed. The user is normally prompted for
 100 removal of any write-protected files which the directory contains. The
 101 write-protected files are removed without prompting, however, if the \fB-f\fR
 102 option is used, or if the standard input is not a terminal and the \fB-i\fR
 103 option is not used.
 104 .sp
 105 Symbolic links that are encountered with this option is not traversed.
 106 .sp
 107 If the removal of a non-empty, write-protected directory is attempted, the
 108 utility always fails (even if the \fB-f\fR option is used), resulting in an
 109 error message.
 110 .RE
 111 
 112 .sp
 113 .ne 2
 114 .na
 115 \fB\fB-R\fR\fR
 116 .ad
 117 .RS 6n
 118 Same as \fB-r\fR option.
 119 .RE
 120 

















 121 .sp
 122 .ne 2
 123 .na
 124 \fB\fB-v\fR\fR
 125 .ad
 126 .RS 6n
 127 Print out the name of files and directories removed.


 128 .RE
 129 
 130 .SS "/usr/bin/rm"
 131 .sp
 132 .LP
 133 The following options are supported for \fB/usr/bin/rm\fR only:
 134 .sp
 135 .ne 2
 136 .na
 137 \fB\fB-f\fR\fR
 138 .ad
 139 .RS 6n
 140 Removes all files (whether write-protected or not) in a directory without
 141 prompting the user.

 142 .RE
 143 
 144 .sp
 145 .ne 2
 146 .na
 147 \fB\fB-i\fR\fR
 148 .ad
 149 .RS 6n
 150 Interactive. With this option, \fBrm\fR prompts for confirmation before
 151 removing any files. It overrides the \fB-f\fR option and remains in effect even
 152 if the standard input is not a terminal.
 153 .RE
 154 
 155 .SS "/usr/bin/rmdir"
 156 .sp
 157 .LP
 158 The following options are supported for \fB/usr/bin/rmdir\fR only:
 159 .sp
 160 .ne 2
 161 .na
 162 \fB\fB-p\fR\fR
 163 .ad
 164 .RS 6n
 165 Allows users to remove the directory \fIdirname\fR and its parent directories
 166 which become empty. A message is printed to standard error if all or part of
 167 the path could not be removed.
 168 .RE
 169 
 170 .sp
 171 .ne 2
 172 .na


 237 
 238 .sp
 239 .ne 2
 240 .na
 241 \fB\fIdirname\fR\fR
 242 .ad
 243 .RS 11n
 244 Specifies the pathname of an empty directory to be removed.
 245 .RE
 246 
 247 .SH USAGE
 248 .sp
 249 .LP
 250 See \fBlargefile\fR(5) for the description of the behavior of \fBrm\fR and
 251 \fBrmdir\fR when encountering files greater than or equal to 2 Gbyte ( 2^31
 252 bytes).
 253 .SH EXAMPLES
 254 .sp
 255 .LP
 256 The following examples are valid for the commands shown.
 257 .SS "/usr/bin/rm"
 258 .LP
 259 \fBExample 1 \fRRemoving Directories
 260 .sp
 261 .LP
 262 The following command removes the directory entries \fBa.out\fR and \fBcore\fR:
 263 
 264 .sp
 265 .in +2
 266 .nf
 267 example% \fBrm a.out core\fR
 268 .fi
 269 .in -2
 270 .sp
 271 
 272 .LP
 273 \fBExample 2 \fRRemoving a Directory without Prompting
 274 .sp
 275 .LP
 276 The following command removes the directory \fBjunk\fR and all its contents,
 277 without prompting:


 363 An error occurred. One or more directories could not be deleted.
 364 .RE
 365 
 366 .SH ATTRIBUTES
 367 .sp
 368 .LP
 369 See \fBattributes\fR(5) for descriptions of the following attributes:
 370 .SS "/usr/bin/rm, /usr/bin/rmdir"
 371 .sp
 372 
 373 .sp
 374 .TS
 375 box;
 376 c | c
 377 l | l .
 378 ATTRIBUTE TYPE  ATTRIBUTE VALUE
 379 _
 380 CSI     Enabled
 381 .TE
 382 

















 383 .SS "ksh93"
 384 .sp
 385 
 386 .sp
 387 .TS
 388 box;
 389 c | c
 390 l | l .
 391 ATTRIBUTE TYPE  ATTRIBUTE VALUE
 392 _
 393 Interface Stability     See below.
 394 .TE
 395 
 396 .sp
 397 .LP
 398 The \fBksh93\fR built-in binding to \fB/bin\fR and \fB/usr/bin\fR is Volatile.
 399 The built-in interfaces are Uncommitted.
 400 .SH SEE ALSO
 401 .sp
 402 .LP