rm(1)
NAME
rm, rmdir − remove files or directories
SYNOPSIS
rm [−f] [−i] filename...
rm −r [−f] [−i] dirname...[filename...]
rmdir [−p] [−s] dirname...
AVAILABILITY
SUNWcsu
DESCRIPTION
rm removes the entries for one or more files from a directory. If a file has no write permission and the standard input is a terminal, the full set of permissions (in octal) for the file are printed followed by a question mark. This is a prompt for confirmation. If the answer begins with y (for yes), the file is deleted, otherwise the file remains.
If filename is a symbolic link, the link will be removed, but the file or directory to which it refers will not be deleted. A user does not need write permission on a symbolic link to remove it, provided they have write permissions in the directory.
Note: If the standard input is not a terminal, the command will operate as if the −f option is in effect.
OPTIONS
The following options apply to rm:
−f Remove all files (whether write-protected or not) in a directory without prompting the user. In a write-protected directory, however, files are never removed (whatever their permissions are), but no messages are displayed. If the removal of a write-protected directory is attempted, this option will not suppress an error message.
−i Interactive. With this option, rm prompts for confirmation before removing any write-protected files. It overrides the −f option and remains in effect even if the standard input is not a terminal.
−r Recursively remove directories and subdirectories in the argument list. The directory will be emptied of files and removed. Note: The user is normally prompted for removal of any write-protected files which the directory contains. The write-protected files are removed without prompting, however, if the −f option is used, or if the standard input is not a terminal and the −i option is not used.
Symbolic links that are encountered with this option will not be traversed.
If the removal of a non-empty, write-protected directory is attempted, the command will always fail (even if the −f option is used), resulting in an error message.
The following options apply to rmdir:
−p Allow users to remove the directory dirname and its parent directories which become empty. A message is printed on the standard output about whether the whole path is removed or part of the path remains for some reason.
−s Suppress the message printed on the standard error when −p is in effect.
ENVIRONMENT
If any of the LC_∗ variables ( LC_CTYPE, LC_MESSAGES, LC_TIME, LC_COLLATE, LC_NUMERIC, and LC_MONETARY ) (see environ(5)) are not set in the environment, the operational behavior of rm for each corresponding locale category is determined by the value of the LANG environment variable. If LC_ALL is set, its contents are used to override both the LANG and the other LC_∗ variables. If none of the above variables is set in the environment, the "C" (U.S. style) locale determines how rm behaves.
LC_CTYPE
Determines how rm handles characters. When LC_CTYPE is set to a valid value, rm can display and handle text and filenames containing valid characters for that locale. rm can display and handle Extended Unix Code (EUC) characters where any individual character can be 1, 2, or 3 bytes wide. rm can also handle EUC characters of 1, 2, or more column widths. In the "C" locale, only characters from ISO 8859-1 are valid.
LC_MESSAGES
Determines how diagnostic and informative messages are presented. This includes the language and style of the messages, and the correct form of affirmative and negative responses. In the "C" locale, the messages are presented in the default form found in the program itself (in most cases, U.S. English).
SEE ALSO
rmdir(2), unlink(2), environ(5)
DIAGNOSTICS
All messages are generally self-explanatory.
It is forbidden to remove the files "." and ".." in order to avoid the consequences of inadvertently doing something like the following:
rm −r .∗
Both rm and rmdir return exit codes of 0 if all the specified directories are removed successfully. Otherwise, they return a non-zero exit code.
NOTES
A −− permits the user to mark explicitly the end of any command line options, allowing rm to recognize filename arguments that begin with a −. As an aid to BSD migration, rm will accept − as a synonym for −−. This migration aid may disappear in a future release. If a −− and a − both appear on the same command line, the second will be interpreted as a filename.
SunOS 5.1/x86 — Last change: 26 Sep 1992