Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ rm(1) — Interactive 3.2r4.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

chmod(1)

rmdir(2)

unlink(2)

RM(1)  —  

NAME

rm, rmdir − remove files or directories

SYNOPSIS

rm [−f] [−i] file ... 

rm −r [−f] [−i] dirname ... [file ...]

rmdir [−p] [−s] dirname ... 

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.  If a directory is writable and has the sticky bit set, files within that directory can be removed only if one or more of the following is true [see unlink(2)]:

the user owns the file
the user owns the directory
the file is writable by the user
the user is the super-user

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. 

Note that if the standard input is not a terminal, the command will operate as if the −f option is in effect. 

The rmdir command removes the named directory if it is empty and the parent directory is writable.  If the parent directory has the sticky bit set, removal occurs only if one of the following is true:

the parent directory is owned by the user
the dirname directory is owned by the user
the dirname directory is writable to the user
the user is the super-user

Three options apply to rm:

−f This option causes the removal of 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 was attempted, this option cannot suppress an error message. 

−r This option causes the recursive removal of any directories and subdirectories in the argument list.  The directory will be emptied of files and removed.  Note that 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.  If the removal of a non-empty, write-protected directory was attempted, the command will always fail (even if the −f option is used), resulting in an error message. 

−i With this option, confirmation of removal of any write-protected file occurs interactively.  It overrides the −f option and remains in effect even if the standard input is not a terminal. 

Two options apply to rmdir:

−p This option allows users to remove the directory dirname and its parent directories which become empty.  A message is printed on standard output as to whether the whole path is removed or part of the path remains for some reason. 

−s This option is used to suppress the message printed on standard error when −p is in effect. 

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. 

SEE ALSO

chmod(1).  rmdir(2), unlink(2) in the INTER­ACTIVE SDS Guide and Programmer’s Reference Manual. 

\*U  —  Version 1.0

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