Name

rm — stdin  stdout  - file  -- opt  --help  --version

Synopsis

rm [options] files | directories

The rm (remove) command can delete files:

rm file1 file2 file3

or recursively delete directories and all their subdirectories:

rm -r dir1 dir2

Useful options

-i

Interactive mode. Ask before deleting each file.

-f

Force the deletion, ignoring any errors or warnings.

-r

Recursively remove a directory and its contents. Use with caution, especially if combined with the -f option, as it can wipe out many files quickly.

[5] A file removed by rm can theoretically be recovered by an undelete program. To remove a file more permanently, say, in a high-security environment, use the srm command instead. See man srm for details.

Get Macintosh Terminal Pocket Guide 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.