O'Reilly logo

Mac OS X Tiger in a Nutshell by Jason McIntosh, Chuck Toporek, Chris Stone, Andy Lester

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

rm

Synopsis

rm [options] files

Deletes one or more files. To remove a file, you must have write permission in the directory that contains the file, but you need not have permission on the file itself. If you don't have write permission on the file, you will be prompted (y or n) to override.

Note that on symbolic links, rm removes the link, not the target file.

If any of the files you're removing begin with a dash, put a -- in front of them. For instance, if you create a file called -f (dash eff), use rm -- -f to remove it.

Options

--

All options following are filenames, not options.

-d

Remove directories, even if they are not empty.

-f

Remove write-protected files without prompting.

-i

Prompt for y (remove the file) or n (don't remove the file).

-P

Cause rm to overwrite files three different times before deleting them.

-r, -R

If file is a directory, remove the entire directory and all its contents, including subdirectories. This option can be dangerous.

-v

Turn on verbose mode. rm prints the name of each file before removing it.

-W

Undelete files on a union filesystem that whiteouts have been applied over.

If any of the files you're removing begin with a dash, put a -- in front of them. Say you create a file called -x:

$ ls > -x
$ rm -x
rm: invalid option -- x
Try 'rm --help' for more information.

The -x is taken as an option to rm. Instead, put the -- in front:

$ rm -- -x

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required