rm removes the entry (link) for one or more files from a directory. You must have write permission for a directory before you can remove a file from it.
Syntax
rm[ option] file... |
No option specified If you have write permission for file, rm removes the entry without issuing a warning. If you do not have write permission for file and the standard input is a terminal, rm prompts you by displaying the permissions and a query ? and asking whether you want the file to be deleted. The entry is not deleted unless you answer the locale’s equivalent of yes. No such confirmation is requested if the standard input is not a terminal. options
Removes the entries without any questions. Files will not be removed if you do not have write permission for the directory.
rm removes files interactively, requesting confirmation for each write-protected file (or directory, if -r is in effect) before removing it. The -i option overrides the -f option and remains in effect even if the standard input is not a terminal.
Accepts a directory name as an argument for file. The usual error message is not issued. rm recursively deletes the entire contents of the directory and also removes the directory itself.
Analagous to -r.
Name of the file that is to be removed. If you include the -r option, file may also be a directory. You can include a number of file/directory arguments. If you specify a file that has several links, only the specified link is removed; the file itself remains intact (the link counter is decremented by one). The file itself is not deleted until you remove the final link. You must have write permission for the directory before you can remove a file from it; but you need not have read or write permission for the file itself. |
Locale
The following environment variables affect the execution of rm: LANG Provide a default value for the internationalization variables that are unset or null. If LANG is unset of null, the corresponding value from the implementation-specific default locale will be used. If any of the internationalization variables contains an invalid setting, the utility will behave as if none of the variables had been defined. LC_ALL If set to a non-empty string value, override the values of all the other internationalization variables. LC_COLLATE Determine the locale for the behavior of ranges, equivalence classes and multicharacter collating elements in extended regular expressions defined for yes/no queries. LC_CTYPE Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments) and the behavior of character classes within regular expressions used in extended regular expressions defined for yes/no queries. LC_MESSAGES Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error. NLSPATH Determine the location of message catalogs for the processing of LC_MESSAGES. |
Example 1
Removal of all files that end in .prog with confirmation:
The links to files exec.prog and code.prog are removed; the others are retained. |
Example 2
Removal of the directory norm with all files and subdirectories.
|
See also
rmdir |