UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 22.22 The su Command Isn't Just for the Superuser Chapter 23Next: 23.2 rm and Its Dangers
 

23. Removing Files

Contents:
The Cycle of Creation and Destruction
rm and Its Dangers
Tricks for Making rm Safer
Answer "Yes" or "No" Forever with yes
Remove Some, Leave Some
A Faster Way to Remove Files Interactively
Safer File Deletion in Some Directories
Safe Delete: Pros and Cons
delete: Protecting Files from Accidental Deletion
Deletion with Prejudice: rm -f
Deleting Files with Odd Names
Using Wildcards to Delete Files with Strange Names
Deleting Files with the Null Name
Handling a Filename Starting with a Dash (-)
Using unlink to Remove a File with a Strange Name
Removing a Strange File by its I-number
Problems Deleting Directories
How Making and Deleting Directories Works
Deleting (BSD) Manual Pages that Aren't Read
Deleting Stale Files
Removing Every File but One
Using find to Clear Out Unneeded Files

23.1 The Cycle of Creation and Destruction

As a computer user, you spend lots of time creating files. Just as the necessary counterpart of life is death, the other side of file creation is deletion. If you never delete any files, you soon have a computer's equivalent of a population explosion: your disks get full, and you have to either spend money (buy and install more disk drives) or figure out which files you don't really need.

In this chapter, we'll talk about ways to get rid of files: how to do it safely, how to get rid of files that don't want to die, and how to find "stale" files, or unused files that have been around for a long time. "Safe" deletion is a particularly interesting topic, because UNIX's rm command is extreme: once you delete a file, it's gone permanently. There are several solutions for working around this problem, letting you (possibly) reclaim files from the dead.

- ML


Previous: 22.22 The su Command Isn't Just for the Superuser UNIX Power ToolsNext: 23.2 rm and Its Dangers
22.22 The su Command Isn't Just for the Superuser Book Index23.2 rm and Its Dangers

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System