Dangerous use of 'rm'

James O'Gorman james at jamesog.net
Thu Jul 6 23:33:13 BST 2006


Stephen Allen wrote:
> 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.  

So alias rm to rm -i and then when you're ready to add the -rf, hit up,
Ctrl-A and then right arrow three times to type -rf. Surely this isn't
too much effort to ensure the safety of your files?

> You can't do this in FreeBSD.

To be honest, this GNU way you mention just sounds plain weird. Why on
earth would you specify switches/options after the parameters?

James




More information about the Ukfreebsd mailing list