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 (
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
file in each of their zillions
of subdirectories, that could waste a lot of disk
It might be better to make one
file in your home directory
hard link (
the rest to it, like:
ln ~/-i .
Second, to save disk blocks, make sure the
file is zero-length - use the
or some other command that puts
characters in the file.