rm(C) 19 June 1992 rm(C) Name rm - remove files or directories Syntax rm [ -fri ] file ... Description The rm command removes the entries for one or more files from a direc- tory. If an entry was the last link to the file, the file is destroyed. Removal of a file requires write permission in its directory, but neither read nor write permission on the file itself. If a file is a symbolic link, the link will be removed, but the file or directory to which it refers will not be deleted. If the user does not have write permission on a specified file and the standard input is a terminal, the user is prompted for confirmation. The file's name and permissions are printed and a line is read from the stan- dard input. If that line begins with y, the file is deleted; otherwise, the file remains. If the -f option is given or if the standard input is not a terminal, no messages are issued; files are simply removed. rm will not delete directories unless the -r option is used. Options The following options are recognized. -f When invoked with the -f option, rm does not prompt the user for con- firmation for files on which the user does not have write permission. The files are simply removed. -r The -r (recursive) option causes rm to recursively delete the entire contents of the any directories specified, and the directories them- selves. Symbolic links encountered with this option will not be traversed. Note that the rmdir(C) command is a safer way of removing directories. -i The -i (interactive) option causes rm to ask whether to delete each file, and if the -r option is in effect, whether to examine each directory. The special option ``--'' can be used to delimit options. For example, a file named ``-f'' could not be removed by rm because the hyphen is inter- preted as an option; the command rm -f would do nothing, since no file is specified. Using rm -- -f removes the file successfully. See also chmod(C), rmdir(C) Notes It is forbidden to remove the file .. to avoid the consequences of inad- vertently doing something like: rm -r .* It is also forbidden to remove the root directory of a given file system. No more than 17 levels of subdirectories can be removed using the -r option. If the ``sticky'' (t) bit is set on a directory, only the owner of a file can remove that file from the directory. See chmod(C) for more informa- tion about ``sticky'' bits. Standards conformance rm is conformant with: AT&T SVID Issue 2; and X/Open Portability Guide, Issue 3, 1989.