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
Article · Português
O comando rm do sistema operacional Unix é usado para apagar arquivos. É uma forma curta de se referir a remove (remover), é semelhante ao del no MS-DOS. Requer muito cuidado com o comando rm* pois apaga tudo sem confirmação por padrão. Normalmente é usado desta maneira: rm nome_do_arquivo Onde nome_do_arquivo é o nome do arquivo a ser removido. Existem vários argumentos que permitem o uso de outras funcionalidades, como o argumento -i que realiza uma pergunta para o usuário antes de apagar cada arquivo. Muitas vezes é feito um alias do comando rm para rm -i de modo a evitar remoção acidental de arquivos. Quando a opção anterior se torna inconveniente dada a quantidade de arquivos a ser removida, ela pode ser cancelada especificando o argumento -f. Geralmente esta opção é usada em conjunto com o argumento -r que remove diretórios e o conteúdo deles de forma recursiva descendo pela árvore de diretórios partindo do diretório especificado. O comando rm -rf ou também rm -rf /* era usado como piada entre os usuários do sistema Unix. Caso este comando seja executado por um usuário administrador na raiz do sistema de arquivos levará a remoção de todos os arquivos que podem ser escritos, trazia a ideia de desastre total.Nas versões mais recentes do rm, rm -rf é um alias para rm -rf --preserve-root, o que impede a remoção de /.. Há também várias chaves para rm * --directory (-d) - Remove um diretório * --force (-f) - Ele não pede autorização para o usuário e ignora os arquivos não localizados. * --recursive (-r ou -R) - Deleta o conteúdo de todos os subdiretórios.
Abstract from DBpedia / Wikipedia · CC BY-SA