Name

rm

Synopsis

    rm [options]files

Delete one or more files. To remove a file, you must have write permission on the directory that contains the file, but you need not have permission on the file itself. If you do not have write permission on the file, you are prompted (y or n) to override.

Common Options

-f, --force

Force. Remove write-protected files without prompting.

-i, --interactive

Prompt for y (remove the file) or n (do not remove the file). Overrides -f.

-r, -R, --recursive

If file is a directory, remove the entire directory and all its contents, including subdirectories. Be forewarned: use of this option can be dangerous.

--

Mark the end of options (rm still accepts -, the old form). Use this when supplying a filename beginning with -.

GNU/Linux and Mac OS X Options

-d, --directory

Remove directories, even if they are not empty. Available only to a privileged user.

-v, --verbose

Verbose mode (print the name of each file before removing it).

GNU/Linux Options

--no-preserve-root

Do not treat the root directory, /, specially.

--preserve-root

Do not operate recursively on the root directory, /.

Mac OS X Options

-P

Overwrite the contents of the to-be-removed files before deleting them. Each file is written with three different bit patterns: 0xff, 0x00, and then 0xff again.

-W

Undelete the named files. Only works for files covered by whiteouts.

Get Unix in a Nutshell, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.