Unix for Mac OS X 10.4 Tiger: Visual QuickPro Guide (2nd Edition)

Deleting Files and Directories

In Unix, when you remove a file or directory, it is gone forever.

In Unix, when you remove a file or directory, it is gone forever.

In Unix, when you remove a file or directory, it is gone forever.

Are we clear on this? The file is not moved to the Trash, where you can go back and retrieve it later. Yes, it is theoretically possible to recover a deleted file, but unless you're with the CIA and have a government agency behind you, don't count on it. (See the sidebar "To Use the Trash from the Command Line.")

To remove a file:

To remove an empty directory:

To remove a directory and everything inside it:

Tips

To Use the Trash from the Command Line

When you use the Finder, the files you put in the Trash are actually moved into a "hidden" directory in your home directory, called .TRash (in Unix, files whose name starts with a . are not normally displayed).

Instead of deleting files, you can move them to the Trash with

mv -i filename ~/.TRash

The -i (for inquire ) option prompts you before overwriting a file with the same name in the .TRash directory. This is different from the Finder behavior in which the filename of the newly trashed file gets changed, instead of the older trashed file of the same name being deleted. (See Chapter 9, "Creating and Using Scripts," for a script that emulates the Finder behavior.)

Категории