2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group. In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document. The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
25 .\" This notice shall appear on any product containing this material.
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
43 .\" Copyright 1989 AT&T
44 .\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
45 .\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures
46 .\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved
54 .Nd remove directory entries
72 utility removes the directory entry specified by each
75 If a file has no write permission and the standard input is a terminal, the
76 full set of permissions (in octal) for the file are printed followed by a
78 This is a prompt for confirmation.
79 If the answer is affirmative, the file is deleted, otherwise the file remains.
83 is a symbolic link, the link is removed, but the file or directory to which it
84 refers is not deleted.
85 Users do not need write permission to remove a symbolic link, provided they
86 have write permissions in the directory.
90 are specified and removal of a
94 writes a diagnostic message to standard error, do nothing more to the current
96 and go on to any remaining
99 If the standard input is not a terminal, the utility operates as if the
105 utility removes the directory entry specified by each
107 operand, which must refer to an empty directory.
109 Directories are processed in the order specified.
110 If a directory and a subdirectory of that directory are specified in a single
113 the subdirectory must be specified before the parent directory so that the
114 parent directory is empty when
122 is associated with the
129 is executed without a pathname prefix and the pathname search finds a
136 deletes each given directory.
137 The directory must be empty and contain no entries other than
142 subdirectory of that directory are specified as operands, the subdirectory must
143 be specified before the parent, so that the parent directory is empty when
145 attempts to remove it.
147 The following options are supported for
151 Recursively removes directories and subdirectories in the argument list.
152 The directory is emptied of files and removed.
153 The user is normally prompted for removal of any write-protected files which
154 the directory contains.
155 The write-protected files are removed without prompting, however, if the
157 option is used, or if the standard input is not a terminal and the
161 Symbolic links that are encountered with this option is not traversed.
163 If the removal of a non-empty, write-protected directory is attempted, the
164 utility always fails (even if the
166 option is used), resulting in an error message.
173 The following options are supported for
178 Removes all files (whether write-protected or not) in a directory without
180 In a write-protected directory, however, files are never removed (whatever
181 their permissions are), but no messages are displayed.
182 If the removal of a write-protected directory is attempted, this option does
183 not suppress an error message.
188 prompts for confirmation before
192 option and remains in effect even if the standard input is not a terminal.
195 The following options are supported for
200 Allows users to remove the directory
202 and its parent directories which become empty.
203 A message is printed to standard error if all or part of the path could not be
206 Suppresses the message printed on the standard error when
211 The following options are supported for the
218 .It Fl -ignore-fail-on-non-empty
219 Ignore each non-empty directory failure.
225 Remove each explicit directory argument directory that becomes empty after its
226 child directories are removed.
232 Suppress the message printed on the standard error when
237 The following operands are supported:
240 Specifies the pathname of a directory entry to be removed.
242 Specifies the pathname of an empty directory to be removed.
247 for the description of the behavior of
251 when encountering files greater than or equal to 2 Gbyte (2^31 bytes).
253 The following exit values are returned:
258 option was not specified, all the named directory entries were
259 removed; otherwise, all the existing named directory entries were removed.
264 The following exit values are returned:
267 Successful completion.
268 All directories deleted successfully.
271 One or more directories could not be deleted.
274 The following examples are valid for the commands shown.
277 .It Sy Example 1 No Removing Directories
279 The following command removes the directory entries
284 .Dl example% rm a.out core
287 .It Sy Example 2 No Removing a Directory without Prompting
289 The following command removes the directory
291 and all its contents, without prompting:
293 .Dl example% rm -rf junk
297 .It Sy Example 3 No Removing Empty Directories
301 in the current directory is empty, except that it contains a directory
305 is empty except that it contains a directory
307 the following command removes all three directories:
309 .Dl example% rmdir -p a/b/c
312 All messages are generally self-explanatory.
314 It is forbidden to remove the files
319 avoid the consequences of inadvertently doing something like the following:
321 .Dl example% rm -r .*
323 It is forbidden to remove the file
325 in order to avoid the consequences of inadvertently doing something like:
327 .Dl example% rm -rf $x/$y
331 .Dl example% rm -rf /$y
337 expand to empty strings.
338 .Sh ENVIRONMENT VARIABLES
341 for descriptions of the following environment variables that affect the
354 Affirmative responses are processed using the extended regular expression
361 The locale specified in the
364 the behavior of ranges, equivalence classes, and multi-character collating
365 elements used in the expression defined for
367 The locale specified in
369 determines the locale for interpretation of sequences of
370 bytes of text data a characters, the behavior of character classes used in the
371 expression defined for the
375 .Sh INTERFACE STABILITY
384 The built-in interfaces are Uncommitted.
397 permits the user to mark explicitly the end of any command line options,
400 to recognize file arguments that begin with a
402 As an aid to BSD migration,
408 This migration aid may disappear in a future release.
413 both appear on the same command line, the second is interpreted as a file.