[Next] [Previous] [Up] [Top] [Contents]

3.7 File Maintenance Commands

3.7.3 rm - remove a file

Remove a file with the rm, remove, command.


rm [options] filename

Common Options

-i interactive (prompt and wait for confirmation before proceeding)

-r recursively remove a directory, first removing the files and subdirectories beneath it

-f don't prompt for confirmation (overrides -i)


% rm old_filename

A listing of the directory will now show that the file no longer exists. Actually, all you've done is to remove the directory table entry and mark the inode as unused. The file contents are still on the disk, but the system now has no way of identifying those data blocks with a file name. There is no command to "unremove" a file that has been removed in this way. For this reason many novice users alias their remove command to be "rm -i", where the -i option prompts them to answer yes or no before the file is removed. Such aliases are normally placed in the .cshrc file for the C shell; see Chapter 5)

Introduction to Unix - 14 AUG 1996
[Next] [Previous] [Up] [Top] [Contents]