and read-only files only protects you from a few occasional mistakes.
A potentially catastrophic error is typing:
rm * .o
In the blink of an eye, all of your files would be gone.
A simple, yet effective, preventive measure is to create a file called
in the particular directory in which you want extra protection:
In the above case, the
is expanded to match all of the filenames in the directory.
Because the file
alphabetically listed (51.3
before any file except those that start with
one of these characters:
command sees the
file as a command-line argument.
is executed with its
files will not be deleted unless you verify the action.
This still isn't perfect. If you have a file that starts with a comma
in the directory, it will come before the file starting with a dash,
will not get the
file also won't save you from errors like:
rm [a-z]* .o
[Two comments about Bruce's classic and handy tip:
first, if lots of users each make a -i
file in each of their zillions
of subdirectories, that could waste a lot of disk
It might be better to make one -i
file in your home directory
hard link (24.4
the rest to it, like:
ln ~/-i .
Second, to save disk blocks, make sure the -i
file is zero-length - use the touch
command, not vi
or some other command that puts
characters in the file. -JP