📄 rm.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>rm</title></head><body bgcolor=white><center><font size=2>The Single UNIX ® Specification, Version 2<br>Copyright © 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_001_014_1878"> </a>NAME</h4><blockquote>rm - remove directory entries</blockquote><h4><a name = "tag_001_014_1879"> </a>SYNOPSIS</h4><blockquote><pre><code>rm <b>[</b>-fiRr<b>]</b><i> file</i>...</code></pre></blockquote><h4><a name = "tag_001_014_1880"> </a>DESCRIPTION</h4><blockquote>The<i>rm</i>utility removes the directory entry specified by each<i>file</i>argument.<p>If either of the files dot or dot-dot are specified as thebasename portion of an operand(that is, the final pathname component),<i>rm</i>will write a diagnosticmessage to standard error and do nothing more with such operands.<p>For each<i>file</i>the following steps are taken:<ol><p><li>If the<i>file</i>does not exist:<ol type = a><p><li>If the<b>-f</b>option is not specified, write a diagnostic messageto standard error.<p><li>Go on to any remaining<i>files</i>.<p></ol><p><li>If<i>file</i>is of type directory, the following steps are taken:<ol type = a><p><li>If neither the<b>-R</b>option nor the<b>-r</b>option is specified,write a diagnostic message to standard error, do nothingmore with<i>file</i>,and go on to any remaining files.<p><li>If the<b>-f</b>option is not specified,and either the permissions of<i>file</i>do not permitwriting and the standard input is a terminal or the<b>-i</b>option is specified, write a prompt tostandard errorand read a line from the standard input.If the responseis not affirmative, do nothing more with the current fileand go on to any remaining files.<p><li>For each entry contained in<i>file</i>,other than dot or dot-dot,the four steps listed here (1-4) are takenwith the entry asif it were a<i>file</i>operand.<p><li>If the<b>-i</b>option is specified, write a prompt tostandard errorand read a line from the standard input.If the response is not affirmative, do nothing more with thecurrent file, and go on to any remaining files.<p></ol><p><li>If<i>file</i>is not of type directory, the<b>-f</b>option is not specified,and either the permissions of<i>file</i>do not permit writingand the standard input is a terminal or the<b>-i</b>option is specified,write a prompt to the standard error and read a line fromthe standard input.If the response is not affirmative, donothing more with the current file and go on to any remaining files.<p><li>If the current file is a directory,<i>rm</i>will perform actions equivalent to the <b>XSH</b> specification<i><a href="../xsh/rmdir.html">rmdir()</a></i>function called with a pathname of the current file used as the<i>path</i>argument.If the current file is not a directory,<i>rm</i>will perform actions equivalent to the <b>XSH</b> specification<i><a href="../xsh/unlink.html">unlink()</a></i>function called with a pathname of the current file used as the<i>path</i>argument.<p>If this fails for any reason,<i>rm</i>will write a diagnostic message to standard error,do nothing more with the current file,and go on to any remaining files.<p></ol><p>The<i>rm</i>utility is able to descend to arbitrary depths in a filehierarchy, and will not fail due to path length limitations (unless anoperand specified by the user exceeds system limitations).</blockquote><h4><a name = "tag_001_014_1881"> </a>OPTIONS</h4><blockquote>The<i>rm</i>utility supports the <b>XBD</b> specification, <a href="../xbd/utilconv.html#usg"><b>Utility Syntax Guidelines</b> </a> .The following options are supported:<dl compact><dt><b>-f</b><dd>Do not prompt for confirmation.Do not write diagnostic messagesor modify the exit status in the case of non-existent operands.Any previous occurrences of the<b>-i</b>option will be ignored.<dt><b>-i</b><dd>Prompt for confirmation as described previously.Any previous occurrences of the<b>-f</b>option will be ignored.<dt><b>-R</b><dd>Remove file hierarchies.See the DESCRIPTION section.<dt><b>-r</b><dd>Equivalent to<b>-R</b>.</dl></blockquote><h4><a name = "tag_001_014_1882"> </a>OPERANDS</h4><blockquote>The following operand is supported:<dl compact><dt><i>file</i><dd>A pathname of a directory entry to be removed.</dl></blockquote><h4><a name = "tag_001_014_1883"> </a>STDIN</h4><blockquote>Used to read an input line in response to each prompt specified inthe STDOUT section.Otherwise, the standard input will not be used.</blockquote><h4><a name = "tag_001_014_1884"> </a>INPUT FILES</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_1885"> </a>ENVIRONMENT VARIABLES</h4><blockquote>The following environment variables affect the execution of<i>rm</i>:<dl compact><dt><i>LANG</i><dd>Provide a default value for the internationalisation variablesthat are unset or null.If<i>LANG</i>is unset or null, the corresponding value from theimplementation-dependent default locale will be used.If any of the internationalisation variables contains an invalid setting, theutility will behave as if none of the variables had been defined.<dt><i>LC_ALL</i><dd>If set to a non-empty string value,override the values of all the other internationalisation variables.<dt><i>LC_COLLATE</i><dd>Determine the locale for thebehaviour of ranges, equivalence classes,and multi-character collating elementsused in the extended regular expression defined for the<b>yesexpr</b>locale keyword in the LC_MESSAGES category.<dt><i>LC_CTYPE</i><dd>Determine thelocale for the interpretation of sequences of bytes of text data ascharacters (for example, single-versus multi-byte characters in arguments) andthe behaviour of character classes within regular expressionsused in the extended regular expression defined for the<b>yesexpr</b>locale keyword in the LC_MESSAGES category.<dt><i>LC_MESSAGES</i><dd>Determine the locale for the processing of affirmative responsesthat should be used to affect the format and contents of diagnosticmessages written to standard error.<dt><i>NLSPATH</i><dd>Determine the location of message cataloguesfor the processing of<i>LC_MESSAGES .</i></dl></blockquote><h4><a name = "tag_001_014_1886"> </a>ASYNCHRONOUS EVENTS</h4><blockquote>Default.</blockquote><h4><a name = "tag_001_014_1887"> </a>STDOUT</h4><blockquote>Not used.</blockquote><h4><a name = "tag_001_014_1888"> </a>STDERR</h4><blockquote>Prompts are written to standard error under the conditionsspecified in the DESCRIPTION and OPTIONS sections.The prompts will contain the<i>file</i>pathname, but their format is otherwise unspecified.The standard error is also used for diagnostic messages.</blockquote><h4><a name = "tag_001_014_1889"> </a>OUTPUT FILES</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_1890"> </a>EXTENDED DESCRIPTION</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_1891"> </a>EXIT STATUS</h4><blockquote>The following exit values are returned:<dl compact><dt>0<dd>If the<b>-f</b>option was not specified, all the named directoryentries were removed; otherwise, all the existing named directoryentries were removed.<dt>>0<dd>An error occurred.</dl></blockquote><h4><a name = "tag_001_014_1892"> </a>CONSEQUENCES OF ERRORS</h4><blockquote>Default.</blockquote><h4><a name = "tag_001_014_1893"> </a>APPLICATION USAGE</h4><blockquote>The<i>rm</i>utility is forbidden to remove the names dot and dot-dotin order to avoid the consequences of inadvertently doing somethinglike:<pre><code>rm -r .*</code></pre><p>Some systems do not permit the removal ofthe last link to an executable binary file that is being executed;see the[EBUSY]error in the <b>XSH</b> specification<i><a href="../xsh/unlink.html">unlink()</a></i>description.Thus, the<i>rm</i>utility can fail to remove such files.<p>The<b>-i</b>option causes<i>rm</i>to prompt and read the standard input even if the standard input isnot a terminal, but in the absence of<b>-i</b>the mode prompting is not done when the standard input is not a terminal.</blockquote><h4><a name = "tag_001_014_1894"> </a>EXAMPLES</h4><blockquote><ol><p><li>The following command:<pre><code>rm a.out core</code></pre>removes the directory entries:<b>a.out</b>and<b>core</b>.<p><li>The following command:<pre><code>rm -Rf junk</code></pre>removes the directory<b>junk</b>and all its contents, without prompting.<p></ol></blockquote><h4><a name = "tag_001_014_1895"> </a>FUTURE DIRECTIONS</h4><blockquote>The IEEE PASC 1003.2 Interpretations Committee has forwarded concerns aboutparts of this interface definition to the IEEE PASC Shell and Utilities Working Groupwhich is identifying the corrections.A future revision of this specification will align withIEEE Std. 1003.2b when finalised.</blockquote><h4><a name = "tag_001_014_1896"> </a>SEE ALSO</h4><blockquote><i><a href="rmdir.html">rmdir</a></i>,the <b>XSH</b> specification description of<i><a href="../xsh/remove.html">remove()</a></i>,<i><a href="../xsh/unlink.html">unlink()</a></i>.<br></blockquote><hr size=2 noshade><center><font size=2>UNIX ® is a registered Trademark of The Open Group.<br>Copyright © 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -