8389 Convert rm(1) manpage to mdoc(5)
[unleashed.git] / usr / src / man / man1 / rm.1
blob6d5983dc4a98f7519ee02e63dc01eba29910b8c0
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 .\" 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]
14 .Dd July 3, 2017
15 .Dt RM 1
16 .Os
17 .Sh NAME
18 .Nm rm ,
19 .Nm rmdir
20 .Nd remove directory entries
21 .Sh SYNOPSIS
22 .Nm /usr/bin/rm
23 .Op Fl f
24 .Op Fl i
25 .Ar
26 .Pp
27 .Nm /usr/bin/rm
28 .Fl rR
29 .Op Fl f
30 .Op Fl i
31 .Ar dirname ...
32 .Op Ar file ...
33 .Pp
34 .Nm /usr/xpg4/bin/rm
35 .Op Fl fiRr
36 .Ar
37 .Pp
38 .Nm /usr/bin/rmdir
39 .Op Fl ps
40 .Ar dirname
41 .Ss "ksh93"
42 .Nm /usr/bin/rmdir
43 .Op Fl eps
44 .Ar dirname ...
45 .Sh DESCRIPTION
46 .Ss "/usr/bin/rm /usr/xpg4/bin/rm"
47 The
48 .Nm rm
49 utility removes the directory entry specified by each
50 .Ar file
51 argument.
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
54 question mark.
55 This is a prompt for confirmation.
56 If the answer is affirmative, the file is deleted, otherwise the file remains.
57 .Pp
59 .Ar file
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.
64 .Pp
65 If multiple
66 .Ar file Ns s
67 are specified and removal of a
68 .Ar file
69 fails for any reason,
70 .Nm rm
71 writes a diagnostic message to standard error, do nothing more to the current
72 .Ar file ,
73 and go on to any remaining
74 .Ar file Ns s .
75 .Pp
76 If the standard input is not a terminal, the utility operates as if the
77 .Fl f
78 option is in effect.
79 .Ss "/usr/bin/rmdir"
80 The
81 .Nm rmdir
82 utility removes the directory entry specified by each
83 .Ar dirname
84 operand, which must refer to an empty directory.
85 .Pp
86 Directories are processed in the order specified.
87 If a directory and a subdirectory of that directory are specified in a single
88 invocation of
89 .Nm rmdir ,
90 the subdirectory must be specified before the parent directory so that the
91 parent directory is empty when
92 .Nm rmdir
93 tries to remove it.
94 .Ss "ksh93"
95 The
96 .Nm rmdir
97 built-in in
98 .Nm ksh93
99 is associated with the
100 .Pa /bin
102 .Pa /usr/bin
103 paths.
104 It is invoked when
105 .Nm rmdir
106 is executed without a pathname prefix and the pathname search finds a
107 .Pa /bin/rmdir
109 .Pa /usr/bin/rmdir
110 executable.
112 .Nm rmdir
113 deletes each given directory.
114 The directory must be empty and contain no entries other than
115 .Pa \&.
117 .Pa .. .
118 If a directory and a
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
121 .Nm rmdir
122 attempts to remove it.
123 .Sh OPTIONS
124 The following options are supported for
125 .Nm /usr/bin/rm
127 .Nm /usr/xpg4/bin/rm :
128 .Bl -hang
129 .It Fl r
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
135 .Fl f
136 option is used, or if the standard input is not a terminal and the
137 .Fl i
138 option is not used.
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
144 .Fl f
145 option is used), resulting in an error message.
146 .It Fl R
147 Same as
148 .Fl r
149 option.
151 .Ss "/usr/bin/rm"
152 The following options are supported for
153 .Nm /usr/bin/rm
154 only:
155 .Bl -hang
156 .It Fl f
157 Removes all files (whether write-protected or not) in a directory without
158 prompting the user.
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.
163 .It Fl i
164 Interactive.
165 With this option,
166 .Nm rm
167 prompts for confirmation before
168 removing any files.
169 It overrides the
170 .Fl f
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
175 .Nm /usr/xpg4/bin/rm
176 only:
177 .Bl -hang
178 .It Fl f
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
183 .Fl i
184 option is ignored.
185 .It Fl i
186 Prompts for confirmation.
187 Any occurrences of the
188 .Fl f
189 option is ignored.
191 .Ss "/usr/bin/rmdir"
192 The following options are supported for
193 .Nm /usr/bin/rmdir
194 only:
195 .Bl -hang
196 .It Fl p
197 Allows users to remove the directory
198 .Ar dirname
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
201 removed.
202 .It Fl s
203 Suppresses the message printed on the standard error when
204 .Fl p
205 is in effect.
207 .Ss "ksh93"
208 The following options are supported for the
209 .Nm rmdir
210 built-in for
211 .Nm ksh93 :
213 .Bl -hang -compact
214 .It Fl e
215 .It Fl -ignore-fail-on-non-empty
216 Ignore each non-empty directory failure.
219 .Bl -hang -compact
220 .It Fl p
221 .It Fl -parents
222 Remove each explicit directory argument directory that becomes empty after its
223 child directories are removed.
226 .Bl -hang -compact
227 .It Fl s
228 .It Fl -suppress
229 Suppress the message printed on the standard error when
230 .Fl p
231 is in effect.
233 .Sh OPERANDS
234 The following operands are supported:
235 .Bl -tag -width Ar
236 .It Ar file
237 Specifies the pathname of a directory entry to be removed.
238 .It Ar dirname
239 Specifies the pathname of an empty directory to be removed.
241 .Sh USAGE
243 .Xr largefile 5
244 for the description of the behavior of
245 .Nm rm
247 .Nm rmdir
248 when encountering files greater than or equal to 2 Gbyte (2^31 bytes).
249 .Sh EXIT STATUS
250 The following exit values are returned:
251 .Bl -tag -width Sy
252 .It Sy 0
253 If the
254 .Fl f
255 option was not specified, all the named directory entries were
256 removed; otherwise, all the existing named directory entries were removed.
257 .It Sy >0
258 An error occurred.
260 .Ss "ksh93"
261 The following exit values are returned:
262 .Bl -tag -width Sy
263 .It Sy 0
264 Successful completion.
265 All directories deleted successfully.
266 .It Sy  >0
267 An error occurred.
268 One or more directories could not be deleted.
270 .Sh EXAMPLES
271 The following examples are valid for the commands shown.
272 .Ss "/usr/bin/rm, /usr/xpg4/bin/rm"
273 .Bl -ohang
274 .It Sy Example 1 No Removing Directories
276 The following command removes the directory entries
277 .Pa a.out
279 .Pa core :
281 .Dl example% rm a.out core
283 .Bl -ohang
284 .It Sy Example 2 No Removing a Directory without Prompting
286 The following command removes the directory
287 .Pa junk
288 and all its contents, without prompting:
290 .Dl example% rm -rf junk
292 .Ss "/usr/bin/rmdir"
293 .Bl -ohang
294 .It Sy Example 3 No Removing Empty Directories
296 If a directory
297 .Pa a
298 in the current directory is empty, except that it contains a directory
299 .Pa b ,
301 .Pa a/b
302 is empty except that it contains a directory
303 .Pa c ,
304 the following command removes all three directories:
306 .Dl example% rmdir -p a/b/c
308 .Sh DIAGNOSTICS
309 All messages are generally self-explanatory.
311 It is forbidden to remove the files
312 .Qq Pa \&.
314 .Qq Pa ..
315 in order to
316 avoid the consequences of inadvertently doing something like the following:
318 .Dl example% rm -r .*
320 It is forbidden to remove the file
321 .Qq Pa /
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
330 when
331 .Va $x
333 .Va $y
334 expand to empty strings.
335 .Sh ENVIRONMENT VARIABLES
337 .Xr environ 5
338 for descriptions of the following environment variables that affect the
339 execution of
340 .Nm rm
342 .Nm rmdir :
343 .Ev LANG ,
344 .Ev LC_ALL ,
345 .Ev LC_COLLATE ,
346 .Ev LC_CTYPE ,
347 .Ev LC_MESSAGES ,
349 .Ev NLSPATH .
351 Affirmative responses are processed using the extended regular expression
352 defined for the
353 .Sy yesexpr
354 keyword in the
355 .Ev LC_MESSAGES
356 category of the
357 user's locale.
358 The locale specified in the
359 .Ev LC_COLLATE
360 category defines
361 the behavior of ranges, equivalence classes, and multi-character collating
362 elements used in the expression defined for
363 .Sy yesexpr .
364 The locale specified in
365 .Ev LC_CTYPE
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
369 .Sy yesexpr .
371 .Xr locale 5 .
372 .Sh INTERFACE STABILITY
373 .Ss "/usr/xpg4/bin/rm"
374 Committed
375 .Ss "ksh93"
377 .Nm ksh93
378 built-in binding to
379 .Pa /bin
381 .Pa /usr/bin
382 is Volatile.
383 The built-in interfaces are Uncommitted.
384 .Sh SEE ALSO
385 .Xr ksh93 1 ,
386 .Xr rmdir 2 ,
387 .Xr rmdir 2 ,
388 .Xr unlink 2 ,
389 .Xr attributes 5 ,
390 .Xr environ 5 ,
391 .Xr largefile 5 ,
392 .Xr standards 5
393 .Sh NOTES
396 permits the user to mark explicitly the end of any command line options,
397 allowing
398 .Nm rm
399 to recognize file arguments that begin with a
400 .Fl .
401 As an aid to BSD migration,
402 .Nm rm
403 accepts
404 .Fl -
405 as a synonym for
406 .Fl .
407 This migration aid may disappear in a future release.
408 If a
409 .Fl -
410 and a
412 both appear on the same command line, the second is interpreted as a file.