logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

rm.1p (12865B)


  1. '\" et
  2. .TH RM "1P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. rm
  12. \(em remove directory entries
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. rm \fB[\fR-iRr\fB]\fI file\fR...
  17. .P
  18. rm -f \fB[\fR-iRr\fB]\fI \fB[\fIfile\fR...\fB]\fR
  19. .fi
  20. .SH DESCRIPTION
  21. The
  22. .IR rm
  23. utility shall remove the directory entry specified by each
  24. .IR file
  25. argument.
  26. .P
  27. If either of the files dot or dot-dot are specified as the basename
  28. portion of an operand (that is, the final pathname component) or if an
  29. operand resolves to the root directory,
  30. .IR rm
  31. shall write a diagnostic message to standard error and do nothing more
  32. with such operands.
  33. .P
  34. For each
  35. .IR file
  36. the following steps shall be taken:
  37. .IP " 1." 4
  38. If the
  39. .IR file
  40. does not exist:
  41. .RS 4
  42. .IP " a." 4
  43. If the
  44. .BR \-f
  45. option is not specified,
  46. .IR rm
  47. shall write a diagnostic message to standard error.
  48. .IP " b." 4
  49. Go on to any remaining
  50. .IR files .
  51. .RE
  52. .IP " 2." 4
  53. If
  54. .IR file
  55. is of type directory, the following steps shall be taken:
  56. .RS 4
  57. .IP " a." 4
  58. If neither the
  59. .BR \-R
  60. option nor the
  61. .BR \-r
  62. option is specified,
  63. .IR rm
  64. shall write a diagnostic message to standard error, do nothing more
  65. with
  66. .IR file ,
  67. and go on to any remaining files.
  68. .IP " b." 4
  69. If
  70. .IR file
  71. is an empty directory,
  72. .IR rm
  73. may skip to step 2d.
  74. If the
  75. .BR \-f
  76. option is not specified, and either the permissions of
  77. .IR file
  78. do not permit writing and the standard input is a terminal or the
  79. .BR \-i
  80. option is specified,
  81. .IR rm
  82. shall write a prompt to standard error and read a line from the
  83. standard input. If the response is not affirmative,
  84. .IR rm
  85. shall do nothing more with the current file and go on to any remaining
  86. files.
  87. .IP " c." 4
  88. For each entry contained in
  89. .IR file ,
  90. other than dot or dot-dot, the four steps listed here (1 to 4) shall be
  91. taken with the entry as if it were a
  92. .IR file
  93. operand. The
  94. .IR rm
  95. utility shall not traverse directories by following symbolic links into
  96. other parts of the hierarchy, but shall remove the links themselves.
  97. .IP " d." 4
  98. If the
  99. .BR \-i
  100. option is specified,
  101. .IR rm
  102. shall write a prompt to standard error and read a line from the
  103. standard input. If the response is not affirmative,
  104. .IR rm
  105. shall do nothing more with the current file, and go on to any remaining
  106. files.
  107. .RE
  108. .IP " 3." 4
  109. If
  110. .IR file
  111. is not of type directory, the
  112. .BR \-f
  113. option is not specified, and either the permissions of
  114. .IR file
  115. do not permit writing and the standard input is a terminal or the
  116. .BR \-i
  117. option is specified,
  118. .IR rm
  119. shall write a prompt to the standard error and read a line from the
  120. standard input. If the response is not affirmative,
  121. .IR rm
  122. shall do nothing more with the current file and go on to any remaining
  123. files.
  124. .IP " 4." 4
  125. If the current file is a directory,
  126. .IR rm
  127. shall perform actions equivalent to the
  128. \fIrmdir\fR()
  129. function defined in the System Interfaces volume of POSIX.1\(hy2017 called with a pathname of the current
  130. file used as the
  131. .IR path
  132. argument. If the current file is not a directory,
  133. .IR rm
  134. shall perform actions equivalent to the
  135. \fIunlink\fR()
  136. function defined in the System Interfaces volume of POSIX.1\(hy2017 called with a pathname of the current
  137. file used as the
  138. .IR path
  139. argument.
  140. .RS 4
  141. .P
  142. If this fails for any reason,
  143. .IR rm
  144. shall write a diagnostic message to standard error, do nothing more
  145. with the current file, and go on to any remaining files.
  146. .RE
  147. .P
  148. The
  149. .IR rm
  150. utility shall be able to descend to arbitrary depths in a file
  151. hierarchy, and shall not fail due to path length limitations (unless an
  152. operand specified by the user exceeds system limitations).
  153. .SH OPTIONS
  154. The
  155. .IR rm
  156. utility shall conform to the Base Definitions volume of POSIX.1\(hy2017,
  157. .IR "Section 12.2" ", " "Utility Syntax Guidelines".
  158. .P
  159. The following options shall be supported:
  160. .IP "\fB\-f\fP" 10
  161. Do not prompt for confirmation. Do not write diagnostic messages or
  162. modify the exit status in the case of no file operands, or in the case
  163. of operands that do not exist. Any previous occurrences of the
  164. .BR \-i
  165. option shall be ignored.
  166. .IP "\fB\-i\fP" 10
  167. Prompt for confirmation as described previously. Any previous
  168. occurrences of the
  169. .BR \-f
  170. option shall be ignored.
  171. .IP "\fB\-R\fP" 10
  172. Remove file hierarchies. See the DESCRIPTION.
  173. .IP "\fB\-r\fP" 10
  174. Equivalent to
  175. .BR \-R .
  176. .SH OPERANDS
  177. The following operand shall be supported:
  178. .IP "\fIfile\fR" 10
  179. A pathname of a directory entry to be removed.
  180. .SH STDIN
  181. The standard input shall be used to read an input line in response to
  182. each prompt specified in the STDOUT section. Otherwise, the standard
  183. input shall not be used.
  184. .SH "INPUT FILES"
  185. None.
  186. .SH "ENVIRONMENT VARIABLES"
  187. The following environment variables shall affect the execution of
  188. .IR rm :
  189. .IP "\fILANG\fP" 10
  190. Provide a default value for the internationalization variables that are
  191. unset or null. (See the Base Definitions volume of POSIX.1\(hy2017,
  192. .IR "Section 8.2" ", " "Internationalization Variables"
  193. for the precedence of internationalization variables used to determine
  194. the values of locale categories.)
  195. .IP "\fILC_ALL\fP" 10
  196. If set to a non-empty string value, override the values of all the
  197. other internationalization variables.
  198. .IP "\fILC_COLLATE\fP" 10
  199. .br
  200. Determine the locale for the behavior of ranges, equivalence classes,
  201. and multi-character collating elements used in the extended regular
  202. expression defined for the
  203. .BR yesexpr
  204. locale keyword in the
  205. .IR LC_MESSAGES
  206. category.
  207. .IP "\fILC_CTYPE\fP" 10
  208. Determine the locale for the interpretation of sequences of bytes of
  209. text data as characters (for example, single-byte as opposed to
  210. multi-byte characters in arguments) and the behavior of character
  211. classes within regular expressions used in the extended regular
  212. expression defined for the
  213. .BR yesexpr
  214. locale keyword in the
  215. .IR LC_MESSAGES
  216. category.
  217. .IP "\fILC_MESSAGES\fP" 10
  218. .br
  219. Determine the locale used to process affirmative responses, and the
  220. locale used to affect the format and contents of diagnostic messages
  221. and prompts written to standard error.
  222. .IP "\fINLSPATH\fP" 10
  223. Determine the location of message catalogs for the processing of
  224. .IR LC_MESSAGES .
  225. .SH "ASYNCHRONOUS EVENTS"
  226. Default.
  227. .SH STDOUT
  228. Not used.
  229. .SH STDERR
  230. Prompts shall be written to standard error under the conditions
  231. specified in the DESCRIPTION and OPTIONS sections. The prompts shall
  232. contain the
  233. .IR file
  234. pathname, but their format is otherwise unspecified. The standard
  235. error also shall be used for diagnostic messages.
  236. .SH "OUTPUT FILES"
  237. None.
  238. .SH "EXTENDED DESCRIPTION"
  239. None.
  240. .SH "EXIT STATUS"
  241. The following exit values shall be returned:
  242. .IP "\00" 6
  243. Each directory entry was successfully removed, unless its removal was
  244. canceled by a non-affirmative response to a prompt for confirmation.
  245. .IP >0 6
  246. An error occurred.
  247. .SH "CONSEQUENCES OF ERRORS"
  248. Default.
  249. .LP
  250. .IR "The following sections are informative."
  251. .SH "APPLICATION USAGE"
  252. The
  253. .IR rm
  254. utility is forbidden to remove the names dot and dot-dot in order to
  255. avoid the consequences of inadvertently doing something like:
  256. .sp
  257. .RS 4
  258. .nf
  259. rm -r .*
  260. .fi
  261. .P
  262. .RE
  263. .P
  264. Some implementations do not permit the removal of the last link to an
  265. executable binary file that is being executed; see the
  266. .BR [EBUSY]
  267. error in the
  268. \fIunlink\fR()
  269. function defined in the System Interfaces volume of POSIX.1\(hy2017. Thus, the
  270. .IR rm
  271. utility can fail to remove such files.
  272. .P
  273. The
  274. .BR \-i
  275. option causes
  276. .IR rm
  277. to prompt and read the standard input even if the standard input is not
  278. a terminal, but in the absence of
  279. .BR \-i
  280. the mode prompting is not done when the standard input is not a
  281. terminal.
  282. .SH EXAMPLES
  283. .IP " 1." 4
  284. The following command:
  285. .RS 4
  286. .sp
  287. .RS 4
  288. .nf
  289. rm a.out core
  290. .fi
  291. .P
  292. .RE
  293. .P
  294. removes the directory entries:
  295. .BR a.out
  296. and
  297. .BR core .
  298. .RE
  299. .IP " 2." 4
  300. The following command:
  301. .RS 4
  302. .sp
  303. .RS 4
  304. .nf
  305. rm -Rf junk
  306. .fi
  307. .P
  308. .RE
  309. .P
  310. removes the directory
  311. .BR junk
  312. and all its contents, without prompting.
  313. .RE
  314. .SH RATIONALE
  315. For absolute clarity, paragraphs (2b) and (3) in the DESCRIPTION of
  316. .IR rm
  317. describing the behavior when prompting for confirmation, should be
  318. interpreted in the following manner:
  319. .sp
  320. .RS 4
  321. .nf
  322. if ((NOT f_option) AND
  323. ((not_writable AND input_is_terminal) OR i_option))
  324. .fi
  325. .P
  326. .RE
  327. .P
  328. The exact format of the interactive prompts is unspecified. Only the
  329. general nature of the contents of prompts are specified because
  330. implementations may desire more descriptive prompts than those used on
  331. historical implementations. Therefore, an application not using the
  332. .BR \-f
  333. option, or using the
  334. .BR \-i
  335. option, relies on the system to provide the most suitable dialog
  336. directly with the user, based on the behavior specified.
  337. .P
  338. The
  339. .BR \-r
  340. option is historical practice on all known systems. The synonym
  341. .BR \-R
  342. option is provided for consistency with the other utilities in this volume of POSIX.1\(hy2017
  343. that provide options requesting recursive descent through the file
  344. hierarchy.
  345. .P
  346. The behavior of the
  347. .BR \-f
  348. option in historical versions of
  349. .IR rm
  350. is inconsistent. In general, along with ``forcing'' the unlink without
  351. prompting for permission, it always causes diagnostic messages to be
  352. suppressed and the exit status to be unmodified for nonexistent
  353. operands and files that cannot be unlinked. In some versions, however,
  354. the
  355. .BR \-f
  356. option suppresses usage messages and system errors as well.
  357. Suppressing such messages is not a service to either shell scripts or
  358. users.
  359. .P
  360. It is less clear that error messages regarding files that cannot be
  361. unlinked (removed) should be suppressed. Although this is historical
  362. practice, this volume of POSIX.1\(hy2017 does not permit the
  363. .BR \-f
  364. option to suppress such messages.
  365. .P
  366. When given the
  367. .BR \-r
  368. and
  369. .BR \-i
  370. options, historical versions of
  371. .IR rm
  372. prompt the user twice for each directory, once before removing its
  373. contents and once before actually attempting to delete the directory
  374. entry that names it. This allows the user to ``prune'' the file
  375. hierarchy walk. Historical versions of
  376. .IR rm
  377. were inconsistent in that some did not do the former prompt for
  378. directories named on the command line and others had obscure prompting
  379. behavior when the
  380. .BR \-i
  381. option was specified and the permissions of the file did not permit
  382. writing. The POSIX Shell and Utilities
  383. .IR rm
  384. differs little from historic practice, but does require that prompts be
  385. consistent. Historical versions of
  386. .IR rm
  387. were also inconsistent in that prompts were done to both standard
  388. output and standard error. This volume of POSIX.1\(hy2017 requires that prompts be done to
  389. standard error, for consistency with
  390. .IR cp
  391. and
  392. .IR mv ,
  393. and to allow historical extensions to
  394. .IR rm
  395. that provide an option to list deleted files on standard output.
  396. .P
  397. The
  398. .IR rm
  399. utility is required to descend to arbitrary depths so that any file
  400. hierarchy may be deleted. This means, for example, that the
  401. .IR rm
  402. utility cannot run out of file descriptors during its descent (that is,
  403. if the number of file descriptors is limited,
  404. .IR rm
  405. cannot be implemented in the historical fashion where one file
  406. descriptor is used per directory level). Also,
  407. .IR rm
  408. is not permitted to fail because of path length restrictions, unless an
  409. operand specified by the user is longer than
  410. {PATH_MAX}.
  411. .P
  412. The
  413. .IR rm
  414. utility removes symbolic links themselves, not the files they refer to,
  415. as a consequence of the dependence on the
  416. \fIunlink\fR()
  417. functionality, per the DESCRIPTION. When removing hierarchies with
  418. .BR \-r
  419. or
  420. .BR \-R ,
  421. the prohibition on following symbolic links has to be made explicit.
  422. .SH "FUTURE DIRECTIONS"
  423. None.
  424. .SH "SEE ALSO"
  425. .IR "\fIrmdir\fR\^"
  426. .P
  427. The Base Definitions volume of POSIX.1\(hy2017,
  428. .IR "Chapter 8" ", " "Environment Variables",
  429. .IR "Section 12.2" ", " "Utility Syntax Guidelines"
  430. .P
  431. The System Interfaces volume of POSIX.1\(hy2017,
  432. .IR "\fIremove\fR\^(\|)",
  433. .IR "\fIrmdir\fR\^(\|)",
  434. .IR "\fIunlink\fR\^(\|)"
  435. .\"
  436. .SH COPYRIGHT
  437. Portions of this text are reprinted and reproduced in electronic form
  438. from IEEE Std 1003.1-2017, Standard for Information Technology
  439. -- Portable Operating System Interface (POSIX), The Open Group Base
  440. Specifications Issue 7, 2018 Edition,
  441. Copyright (C) 2018 by the Institute of
  442. Electrical and Electronics Engineers, Inc and The Open Group.
  443. In the event of any discrepancy between this version and the original IEEE and
  444. The Open Group Standard, the original IEEE and The Open Group Standard
  445. is the referee document. The original Standard can be obtained online at
  446. http://www.opengroup.org/unix/online.html .
  447. .PP
  448. Any typographical or formatting errors that appear
  449. in this page are most likely
  450. to have been introduced during the conversion of the source files to
  451. man page format. To report such errors, see
  452. https://www.kernel.org/doc/man-pages/reporting_bugs.html .