Skip to content
EntityQ274336· pop 32· linked from 243 articles

basic UNIX command used to remove objects such as files and directories

Described at

The rm utility shall remove the directory entry specified by each file argument. Prompt for confirmation as described previously. Any previous occurrences of the -f option shall be ignored. The standard input shall be used to read an input line in response to each prompt specified in the STDOUT section. Otherwise, the standard input shall not be used. Provide a default value for the internationalization variables that are unset or null. (See XBD Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.) If set to a non-empty string value, override the values of all the other internationalization variables. Determine the locale for the behavior of ranges, equivalence classes, and multi-character collating elements used in the extended regular expression defined for the yesexpr locale keyword in the LC MESSAGES category. Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multi-byte characters in arguments) and the behavior of character classes within regular expressions used in the extended regular expression defined for the yesexpr locale keyword in the LC MESSAGES category. Determine the locale used to process affirmative responses, and the locale used to affect the format and contents of diagnostic messages and prompts written to standard error. [XSI) ] ![[Option Start]]( Determine the location of message catalogs for the processing of LC MESSAGES. ![[Option End]]( Prompts shall be written to standard error under the conditions specified in the DESCRIPTION and OPTIONS sections. The prompts shall contain the file pathname, but their format is otherwise unspecified. The standard error also shall be used for diagnostic messages. Each directory entry was successfully removed, unless its removal was canceled by a non-affirmative response to a prompt for confirmation. Some implementations do not permit the removal of the last link to an executable binary file that is being executed; see the [EBUSY] error in the unlink () function defined in the System Interfaces volume of POSIX.1-2017. Thus, the rm utility can fail to remove such files. The exact format of the interactive prompts is unspecified. Only the general nature of the contents of prompts are specified because implementations may desire more descriptive prompts than those used on historical implementations. Therefore, an application not using the -f option, or using the -i option, relies on the system to provide the most suitable dialog directly with the user, based on the behavior specified. The -r option is historical practice on all known systems. The synonym -R option is provided for consistency with the other utilities in this volume of POSIX.1-2017 that provide options requesting recursive descent through the file hierarchy. It is less clear that error messages regarding files that cannot be unlinked (removed) should be suppressed. Although this is historical practice, this volume of POSIX.1-2017 does not permit the -f option to suppress such messages. When given the -r and -i options, historical versions of rm prompt the user twice for each directory, once before removing its contents and once before actually attempting to delete the directory entry that names it. This allows the user to "prune" the file hierarchy walk. Historical versions of rm were inconsistent in that some did not do the former prompt for directories named on the command line and others had obscure prompting behavior when the -i option was specified and the permissions of the file did not permit writing. The POSIX Shell and Utilities rm differs little from historic practice, but does require that prompts be consistent. Historical versions of rm were also inconsistent in that prompts were done to both standard output and standard error. This volume of POSIX.1-2017 requires that prompts be done to standard error, for consistency

Excerpt from a page describing this subject · 14,742 chars · not written by Vinony

Wikidata facts

Image
Rm --help Command - Unix.png
Show 3 more facts
has command line option
r
Commons category
Rm (Unix)
Sources (2)

via Wikidata · CC0

Article · 中文

rm,是一个基本的UNIX命令,其名称源自英文单词remove的缩写,用于删除文件系统中的文件、目录、设备文件、符号链接等对象。准确地说,rm移除的指向特定对象的引用。在文件系统中,这些特定的对象可能有多个引用(例如,两个不同的文件名可能指向相同的文件), 只有在一个对象不再有任何引用,并且没有任何程序还拥有这个文件的有效句柄的时候,这个文件才会被删除。 这一机制允许下列出现:某个程序可以创建一个文件,并立即将此文件从文件系统中移除,并将这个文件占用的空间作为临时空间使用。(因为在该程序退出甚至是崩溃的时候,这一文件占用的空间会被回收。) rm命令一般来说并不摧毁文件数据,因为其目的仅仅在于解除引用。即便文件已经解除所有的引用,在文件系统中,被释放的空间里可能还会有被删除文件的残留数据。在一些情况下这会带来安全问题,因此有时加强版的命令会在文件的最后一个链接断开之后抹除被删除文件的数据。此外,一些程序(例如:shred)可以提供数据抹除能力。

Abstract from DBpedia / Wikipedia · CC BY-SA