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 -i 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
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
The -i 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 and the rest to it, like: