Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 08 May 2007 12:28:51 +0200
From:      Bernd Trippel <trip@nosubject.org>
To:        freebsd-questions@freebsd.org,  ray@stilltech.net,  carpetsmoker@rwxrwxrwx.net
Subject:   Re: disaster recovery - did I do the right thing?
Message-ID:  <464050E3.4010904@nosubject.org>
In-Reply-To: <20070506032313.GA6098@glitch.rwxrwxrwx.net>
References:  <200705051705.43504.ray@stilltech.net>	<20070506005530.GA5251@glitch.rwxrwxrwx.net>	<463D2B0C.2030603@u.washington.edu> <20070506032313.GA6098@glitch.rwxrwxrwx.net>

next in thread | previous in thread | raw e-mail | index | archive | help
Martin Tournoij typed on 06/05/07 05:23:
> On Sat 05 May 2007 18:05, Garrett Cooper wrote:
>> Martin Tournoij wrote:
>>> On Sat 05 May 2007 17:05, Ray wrote:
>>>> Hello all,
>>>> I did something stupid the other day (sleep deprivation combined with a "clever" hack were the main reasons), and I'm just curious if I did 
>>>> the right thing afterwards.
>>>>
>>>> The mistake:
>>>> /usr/local/# rm -f *
>>>> note that root was running bash as a shell at the time, found in /usr/local/bin or something.
>>>>
>>>> What I did was to start over, reinstall from scratch.
>>>> my question, was there an easier way?
>>>> thanks,
>>>> Ray 
>>> You can use pkg_info -ga to check for missing files in your packages.
>> For (t)csh:
>> alias rm "rm -i"
>>
>> For (ba)sh:
>> alias rm="rm -i"
>>
>> Now that you've learned :).
>>
>> Martin's suggestion is good though -- would have done that considering that all that lived in /usr/local were ports.
>>
>> -Garrett
> 
> The problem with this is that it will ask confirmation for every file it
> deleted.
> Which is gets pretty annoying after a while, also, if you delete a
> directory containing a 100 files, you will have to press 'y' a 100
> times.
> This will probably lead to the habit of using 'rm -f', and/or simply
> pressing y all the time without actually looking at the confirmation
> message.
> In any case, it's not likely to prevent any such accidents.
> 
For the sake of it: You could use rm -I:
quoting the rm man page:
-I  Request confirmation once if more than three files are being
    removed or if a directory is being recursively removed.
    This is a far less intrusive option than -i yet provides almost
    the same level of protection against mistakes.

Output looks like this:
# rm -fI *
remove 10 files?

Would even be better if it would list e.g. 2 or 3 files.

> A better solution would be to write a script that would move files
> instead of deleting them.
> You should name this script to something else than rm, when you're
> working with a new or "foreign" system, you will expect rm to move
> files, instead of deleting them ... and we can all see another
> disaster coming there...

true, sometimes fingers have a memory of their own ;)
> 
> Another hint would be the 'rmstar' option in tcsh, when set, tcsh will
> ask confirmation before executing 'rm *'.
> 
> Note that aliasing 'cp' and 'mv' to 'cp -i' and 'mv -i' is an
> *extremely* wise idea, in the past I have often accidentally overwritten
> files that should not have been overwritten, leading to various
> problems.
> 




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?464050E3.4010904>