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 .\" Copyright 2017 Joyent, Inc.
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]
20 .Nd remove directory entries
46 .Ss "/usr/bin/rm /usr/xpg4/bin/rm"
49 utility removes the directory entry specified by each
52 If a file has no write permission and the standard input is a terminal, the
53 full set of permissions (in octal) for the file are printed followed by a
55 This is a prompt for confirmation.
56 If the answer is affirmative, the file is deleted, otherwise the file remains.
60 is a symbolic link, the link is removed, but the file or directory to which it
61 refers is not deleted.
62 Users do not need write permission to remove a symbolic link, provided they
63 have write permissions in the directory.
67 are specified and removal of a
71 writes a diagnostic message to standard error, do nothing more to the current
73 and go on to any remaining
76 If the standard input is not a terminal, the utility operates as if the
82 utility removes the directory entry specified by each
84 operand, which must refer to an empty directory.
86 Directories are processed in the order specified.
87 If a directory and a subdirectory of that directory are specified in a single
90 the subdirectory must be specified before the parent directory so that the
91 parent directory is empty when
99 is associated with the
106 is executed without a pathname prefix and the pathname search finds a
113 deletes each given directory.
114 The directory must be empty and contain no entries other than
119 subdirectory of that directory are specified as operands, the subdirectory must
120 be specified before the parent, so that the parent directory is empty when
122 attempts to remove it.
124 The following options are supported for
127 .Nm /usr/xpg4/bin/rm :
130 Recursively removes directories and subdirectories in the argument list.
131 The directory is emptied of files and removed.
132 The user is normally prompted for removal of any write-protected files which
133 the directory contains.
134 The write-protected files are removed without prompting, however, if the
136 option is used, or if the standard input is not a terminal and the
140 Symbolic links that are encountered with this option is not traversed.
142 If the removal of a non-empty, write-protected directory is attempted, the
143 utility always fails (even if the
145 option is used), resulting in an error message.
152 The following options are supported for
157 Removes all files (whether write-protected or not) in a directory without
159 In a write-protected directory, however, files are never removed (whatever
160 their permissions are), but no messages are displayed.
161 If the removal of a write-protected directory is attempted, this option does
162 not suppress an error message.
167 prompts for confirmation before
171 option and remains in effect even if the standard input is not a terminal.
173 .Ss "/usr/xpg4/bin/rm"
174 The following options are supported for
179 Does not prompt for confirmation.
180 Does not write diagnostic messages or modify the exit status in the case of
181 non-existent operands.
182 Any previous occurrences of the
186 Prompts for confirmation.
187 Any occurrences of the
192 The following options are supported for
197 Allows users to remove the directory
199 and its parent directories which become empty.
200 A message is printed to standard error if all or part of the path could not be
203 Suppresses the message printed on the standard error when
208 The following options are supported for the
215 .It Fl -ignore-fail-on-non-empty
216 Ignore each non-empty directory failure.
222 Remove each explicit directory argument directory that becomes empty after its
223 child directories are removed.
229 Suppress the message printed on the standard error when
234 The following operands are supported:
237 Specifies the pathname of a directory entry to be removed.
239 Specifies the pathname of an empty directory to be removed.
244 for the description of the behavior of
248 when encountering files greater than or equal to 2 Gbyte (2^31 bytes).
250 The following exit values are returned:
255 option was not specified, all the named directory entries were
256 removed; otherwise, all the existing named directory entries were removed.
261 The following exit values are returned:
264 Successful completion.
265 All directories deleted successfully.
268 One or more directories could not be deleted.
271 The following examples are valid for the commands shown.
272 .Ss "/usr/bin/rm, /usr/xpg4/bin/rm"
274 .It Sy Example 1 No Removing Directories
276 The following command removes the directory entries
281 .Dl example% rm a.out core
284 .It Sy Example 2 No Removing a Directory without Prompting
286 The following command removes the directory
288 and all its contents, without prompting:
290 .Dl example% rm -rf junk
294 .It Sy Example 3 No Removing Empty Directories
298 in the current directory is empty, except that it contains a directory
302 is empty except that it contains a directory
304 the following command removes all three directories:
306 .Dl example% rmdir -p a/b/c
309 All messages are generally self-explanatory.
311 It is forbidden to remove the files
316 avoid the consequences of inadvertently doing something like the following:
318 .Dl example% rm -r .*
320 It is forbidden to remove the file
322 in order to avoid the consequences of inadvertently doing something like:
324 .Dl example% rm -rf $x/$y
328 .Dl example% rm -rf /$y
334 expand to empty strings.
335 .Sh ENVIRONMENT VARIABLES
338 for descriptions of the following environment variables that affect the
351 Affirmative responses are processed using the extended regular expression
358 The locale specified in the
361 the behavior of ranges, equivalence classes, and multi-character collating
362 elements used in the expression defined for
364 The locale specified in
366 determines the locale for interpretation of sequences of
367 bytes of text data a characters, the behavior of character classes used in the
368 expression defined for the
372 .Sh INTERFACE STABILITY
373 .Ss "/usr/xpg4/bin/rm"
383 The built-in interfaces are Uncommitted.
396 permits the user to mark explicitly the end of any command line options,
399 to recognize file arguments that begin with a
401 As an aid to BSD migration,
407 This migration aid may disappear in a future release.
412 both appear on the same command line, the second is interpreted as a file.