Unleashed v1.4
[unleashed.git] / share / man / man1 / rm.1
blobb4303abb2e2253d3dde48d0fd6db603834e9d836
1 .\"
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/.
6 .\"
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
9 .\" documentation.
10 .\"
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
13 .\"
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.
24 .\"
25 .\" This notice shall appear on any product containing this material.
26 .\"
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.
30 .\"
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.
35 .\"
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]
41 .\"
42 .\"
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
47 .\"
48 .Dd July 3, 2017
49 .Dt RM 1
50 .Os
51 .Sh NAME
52 .Nm rm ,
53 .Nm rmdir
54 .Nd remove directory entries
55 .Sh SYNOPSIS
56 .Nm /usr/bin/rm
57 .Op Fl f
58 .Op Fl i
59 .Ar
60 .Pp
61 .Nm /usr/bin/rmdir
62 .Op Fl ps
63 .Ar dirname
64 .Ss "ksh93"
65 .Nm /usr/bin/rmdir
66 .Op Fl eps
67 .Ar dirname ...
68 .Sh DESCRIPTION
69 .Ss "/usr/bin/rm"
70 The
71 .Nm rm
72 utility removes the directory entry specified by each
73 .Ar file
74 argument.
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
77 question mark.
78 This is a prompt for confirmation.
79 If the answer is affirmative, the file is deleted, otherwise the file remains.
80 .Pp
82 .Ar file
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.
87 .Pp
88 If multiple
89 .Ar file Ns s
90 are specified and removal of a
91 .Ar file
92 fails for any reason,
93 .Nm rm
94 writes a diagnostic message to standard error, do nothing more to the current
95 .Ar file ,
96 and go on to any remaining
97 .Ar file Ns s .
98 .Pp
99 If the standard input is not a terminal, the utility operates as if the
100 .Fl f
101 option is in effect.
102 .Ss "/usr/bin/rmdir"
104 .Nm rmdir
105 utility removes the directory entry specified by each
106 .Ar dirname
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
111 invocation of
112 .Nm rmdir ,
113 the subdirectory must be specified before the parent directory so that the
114 parent directory is empty when
115 .Nm rmdir
116 tries to remove it.
117 .Ss "ksh93"
119 .Nm rmdir
120 built-in in
121 .Nm ksh93
122 is associated with the
123 .Pa /bin
125 .Pa /usr/bin
126 paths.
127 It is invoked when
128 .Nm rmdir
129 is executed without a pathname prefix and the pathname search finds a
130 .Pa /bin/rmdir
132 .Pa /usr/bin/rmdir
133 executable.
135 .Nm rmdir
136 deletes each given directory.
137 The directory must be empty and contain no entries other than
138 .Pa \&.
140 .Pa .. .
141 If a directory and a
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
144 .Nm rmdir
145 attempts to remove it.
146 .Sh OPTIONS
147 The following options are supported for
148 .Nm /usr/bin/rm
149 .Bl -hang
150 .It Fl r
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
156 .Fl f
157 option is used, or if the standard input is not a terminal and the
158 .Fl i
159 option is not used.
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
165 .Fl f
166 option is used), resulting in an error message.
167 .It Fl R
168 Same as
169 .Fl r
170 option.
172 .Ss "/usr/bin/rm"
173 The following options are supported for
174 .Nm /usr/bin/rm
175 only:
176 .Bl -hang
177 .It Fl f
178 Removes all files (whether write-protected or not) in a directory without
179 prompting the user.
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.
184 .It Fl i
185 Interactive.
186 With this option,
187 .Nm rm
188 prompts for confirmation before
189 removing any files.
190 It overrides the
191 .Fl f
192 option and remains in effect even if the standard input is not a terminal.
194 .Ss "/usr/bin/rmdir"
195 The following options are supported for
196 .Nm /usr/bin/rmdir
197 only:
198 .Bl -hang
199 .It Fl p
200 Allows users to remove the directory
201 .Ar dirname
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
204 removed.
205 .It Fl s
206 Suppresses the message printed on the standard error when
207 .Fl p
208 is in effect.
210 .Ss "ksh93"
211 The following options are supported for the
212 .Nm rmdir
213 built-in for
214 .Nm ksh93 :
216 .Bl -hang -compact
217 .It Fl e
218 .It Fl -ignore-fail-on-non-empty
219 Ignore each non-empty directory failure.
222 .Bl -hang -compact
223 .It Fl p
224 .It Fl -parents
225 Remove each explicit directory argument directory that becomes empty after its
226 child directories are removed.
229 .Bl -hang -compact
230 .It Fl s
231 .It Fl -suppress
232 Suppress the message printed on the standard error when
233 .Fl p
234 is in effect.
236 .Sh OPERANDS
237 The following operands are supported:
238 .Bl -tag -width Ar
239 .It Ar file
240 Specifies the pathname of a directory entry to be removed.
241 .It Ar dirname
242 Specifies the pathname of an empty directory to be removed.
244 .Sh EXIT STATUS
245 The following exit values are returned:
246 .Bl -tag -width Sy
247 .It Sy 0
248 If the
249 .Fl f
250 option was not specified, all the named directory entries were
251 removed; otherwise, all the existing named directory entries were removed.
252 .It Sy >0
253 An error occurred.
255 .Ss "ksh93"
256 The following exit values are returned:
257 .Bl -tag -width Sy
258 .It Sy 0
259 Successful completion.
260 All directories deleted successfully.
261 .It Sy  >0
262 An error occurred.
263 One or more directories could not be deleted.
265 .Sh EXAMPLES
266 The following examples are valid for the commands shown.
267 .Ss "/usr/bin/rm"
268 .Bl -ohang
269 .It Sy Example 1 No Removing Directories
271 The following command removes the directory entries
272 .Pa a.out
274 .Pa core :
276 .Dl example% rm a.out core
278 .Bl -ohang
279 .It Sy Example 2 No Removing a Directory without Prompting
281 The following command removes the directory
282 .Pa junk
283 and all its contents, without prompting:
285 .Dl example% rm -rf junk
287 .Ss "/usr/bin/rmdir"
288 .Bl -ohang
289 .It Sy Example 3 No Removing Empty Directories
291 If a directory
292 .Pa a
293 in the current directory is empty, except that it contains a directory
294 .Pa b ,
296 .Pa a/b
297 is empty except that it contains a directory
298 .Pa c ,
299 the following command removes all three directories:
301 .Dl example% rmdir -p a/b/c
303 .Sh DIAGNOSTICS
304 All messages are generally self-explanatory.
306 It is forbidden to remove the files
307 .Qq Pa \&.
309 .Qq Pa ..
310 in order to
311 avoid the consequences of inadvertently doing something like the following:
313 .Dl example% rm -r .*
315 It is forbidden to remove the file
316 .Qq Pa /
317 in order to avoid the consequences of inadvertently doing something like:
319 .Dl example% rm -rf $x/$y
323 .Dl example% rm -rf /$y
325 when
326 .Va $x
328 .Va $y
329 expand to empty strings.
330 .Sh ENVIRONMENT VARIABLES
332 .Xr environ 5
333 for descriptions of the following environment variables that affect the
334 execution of
335 .Nm rm
337 .Nm rmdir :
338 .Ev LANG ,
339 .Ev LC_ALL ,
340 .Ev LC_COLLATE ,
341 .Ev LC_CTYPE ,
342 .Ev LC_MESSAGES ,
344 .Ev NLSPATH .
346 Affirmative responses are processed using the extended regular expression
347 defined for the
348 .Sy yesexpr
349 keyword in the
350 .Ev LC_MESSAGES
351 category of the
352 user's locale.
353 The locale specified in the
354 .Ev LC_COLLATE
355 category defines
356 the behavior of ranges, equivalence classes, and multi-character collating
357 elements used in the expression defined for
358 .Sy yesexpr .
359 The locale specified in
360 .Ev LC_CTYPE
361 determines the locale for interpretation of sequences of
362 bytes of text data a characters, the behavior of character classes used in the
363 expression defined for the
364 .Sy yesexpr .
366 .Xr locale 5 .
367 .Sh INTERFACE STABILITY
368 .Ss "ksh93"
370 .Nm ksh93
371 built-in binding to
372 .Pa /bin
374 .Pa /usr/bin
375 is Volatile.
376 The built-in interfaces are Uncommitted.
377 .Sh SEE ALSO
378 .Xr ksh93 1 ,
379 .Xr rmdir 2 ,
380 .Xr rmdir 2 ,
381 .Xr unlink 2 ,
382 .Xr attributes 5 ,
383 .Xr environ 5 ,
384 .Xr standards 5
385 .Sh NOTES
388 permits the user to mark explicitly the end of any command line options,
389 allowing
390 .Nm rm
391 to recognize file arguments that begin with a
392 .Fl .
393 As an aid to BSD migration,
394 .Nm rm
395 accepts
396 .Fl -
397 as a synonym for
398 .Fl .
399 This migration aid may disappear in a future release.
400 If a
401 .Fl -
402 and a
404 both appear on the same command line, the second is interpreted as a file.