Dangerous use of 'rm'

Stephen Allen freebsduk at rowyerboat.com
Thu Jul 6 23:19:33 BST 2006

Gerald Davies wrote:
> don't you do that anyway? *boggles*.

Not on my test box, no.

> yes, i have -i aliased on most boxes too, anything dangerous then use 
> sudo too.
> :) i can't help you if you have bad habits. hehe.

Let's say for example, you have directories called inv and invoices, and 
you want to remove ~/admin/2006/stores/invoices.  The directory contains 
thousands of files, so you're obliged to use rm -rf.

You're using auto-complete and you get as far as 'rm -rf 
admin/2006/stores/inv' and you hit enter because you weren't expecting 
auto complete to stop at inv.  Now you've lost all the wrong files.

The way I get around this on Linux is to omit the -rf, knowing the 
command to remove the directory will fail.  When it fails I then know 
it's the right one, so I just use the command history (up arrow) and add 
-rf to the end of the command.  You can't do this in FreeBSD.

Can you see what I'm asking now?

Steve :)

More information about the Ukfreebsd mailing list