Removing Files

Use the rm command to remove (delete) one or more files, for example:

rm acme doc/report7 /data/acme

The rm command cannot remove directories:

$ rm /tmp
rm: /tmp: is a directory
$

Previously, the text discussed confirmation requests for rm and mv. If you want to prevent getting a confirmation request when you delete another user’s file that you don’t have permission to modify, use the rm -f option to force the removal without asking for confirmation. This is useful when you are deleting a group of files belonging to several users that you are sure you want to delete. This option will also suppress any error message if the file does not exist.

If you are deleting a group of files, you can use the rm -i option to display each filename ...

Get Practical UNIX now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.