Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

unlink(2)

acl(5)

rm(1)

NAME

rm − remove files or directories

SYNOPSIS

rm [-f|-i] [-Rr] file ...

DESCRIPTION

rm removes the entries for one or more files from a directory.  If an entry was the last link to the file, the file is destroyed.  Removal of a file requires write and search (execute) permission in its directory, but no permissions on the file itself; but if the sticky bit is set on the directory containing the file, only the owner of the file, the owner of the directory, or a user having appropriate privileges can remove the file. 

If a user does not have write permission for a file to be removed and the standard input is a terminal, a prompt containing the file name and its permissions is printed requesting that the removal of the file be confirmed (see Access Control Lists below).  A line is then read from the standard input.  If that line begins with y the file is deleted; otherwise, the file remains.  No questions are asked when the -f option is given or if the standard input is not a terminal. 

If file is of type directory, and -f option is not specified, and either the permissions of file do not permit writing and the standard input is a terminal or the -i option is specified, rm writes a prompt to standard error and reads a line form the standard input.  If the response is not affirmative, it does nothing more with the current file and goes on to any remaining files. 

Options

rm recognizes the following options:

-f Force each file or directory to be removed without prompting for confirmation, regardless of the permissions of the entry.  This option also suppresses diagnostic messages regarding non-existent operands. 

This option does not suppress any diagnostic messages other than those regarding non-existent operands.  To suppress all error message and interactive prompts, the -f option should be used while redirecting the standard error output to /dev/null.

-i Write a prompt to the standard error output requesting confirmation before removing each entry.  This option is ignored when used in conjunction with the -f option. 

-R For each argument that is a directory, this option causes rm to recursively delete the entire contents of that directory before removing the directory itself.  When used in conjunction with the -i option, rm asks whether to examine each directory before interactively removing files in that directory and again afterward to confirm removing the directory itself. 

-r Equivalent to -R. 

Access Control Lists (ACLs).

If a file has optional ACL entries, rm displays a plus sign (+) after the file’s permissions.  The permissions shown summarize the file’s st_mode value returned by stat() (see stat(2)). See also acl(5).

EXTERNAL INFLUENCES

Environment Variables

LC_CTYPE determines the interpretation of filenames as single and/or multi-byte characters for the rm command. 

LANG determines the language in which messages are displayed and determines the local language equivalent of y (for yes/no) queries. 

If LC_CTYPE is not specified in the environment or is set to the empty string, the value of LANG is used as a default for each unspecified or empty variable.  If LANG is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of LANG.  If any internationalization variable contains an invalid setting, rm behaves as if all internationalization variables are set to "C".  See environ(5).

International Code Set Support

Single- and multi-byte character code sets are supported. 

DIAGNOSTICS

Generally self-explanatory.  Note that the -f option does not suppress all diagnostic messages. 

It is forbidden to remove the file ..  in order to avoid the consequences of inadvertently using a command such as:

rm -r .*

If a designated file is a directory, an error comment is printed unless the -R or -r option is used. 

EXAMPLES

Remove files with a prompt for verification:

rm -i filenames

Remove all the files in a directory:

rm -i directoryname/*

Note that this command removes files only, and does not remove any directories in directoryname.

Remove file in current directory whose name starts with - or some other character that is special to the shell:

rm ./-filename
rm ./\*filename
etc.

Remove file in current directory whose name starts with some strange (usually non-printing, invisible) character or perhaps has spaces at the beginning or end of the filename:

rm ./*filename*

*filename* must be unique in the directory or other files will also be removed. 

A powerful and dangerous command to remove a directory is:

rm -fR directoryname

or

rm -Rf directoryname

which removes all files and directories from directoryname without any prompting for verification to remove the files or the directories.  This command should only be used when absolutely certain that all the files and directories in directoryname as well as directoryname itself are to be removed. 

DEPENDENCIES

NFS

rm does not display a plus sign (+) to indicate the existence of optional access control list entries when asking for confirmation before removing a networked file. 

SEE ALSO

unlink(2), acl(5). 

STANDARDS CONFORMANCE

rm: SVID2, XPG2, XPG3, POSIX.2

rmdir: SVID2, XPG2, XPG3, POSIX.2

Hewlett-Packard Company  —  HP-UX Release 9.0: August 1992

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026