RE: major blunders

  • From: Fmhabash <fmhabash@xxxxxxxxx>
  • To: Aaron Leonard <aachleon@xxxxxxxxx>, <jkstill@xxxxxxxxx>
  • Date: Sat, 10 Oct 2009 07:45:53 -0400

If you mean changing the behavior of the'rm' cmd. We basically put an autoload 
call for an 'rm' user defined function that is interactive. If you or a script 
needs to use it, they simply use '/bin/rm' which is the default 'rm'. So the 
only way you can delete is by explicitly typing the entire path to the 'rm' cmd 
which requires some high level conscious decision on your part and a reminder 
that you are on a production box.
E.g.
> rm test.log
This is a production box. Are you sure (Y|N):

> /bin/rm test.log
Works as expected.

 
---------------
Thank You.

-----Original Message-----
From: Aaron Leonard <aachleon@xxxxxxxxx>
Sent: Friday, October 09, 2009 1:57 PM
To: jkstill@xxxxxxxxx
Cc: fmhabash@xxxxxxxxx; oracle-l@xxxxxxxxxxxxx; oracle-l-bounce@xxxxxxxxxxxxx
Subject: Re: major blunders

I'd be very wary of relying on that.  It doesn't account for when you are
not in the directory which contain the files your are deleting.

oracle:~/adl/tmp> for i in 1 2 3 4 5 6 7; do echo 1 > file$i; done
oracle:~/adl/tmp> touch -- -i
oracle:~/adl/tmp> rm -f *
rm: remove regular file `file1'?
oracle:~/adl/tmp> rm -f *
rm: remove regular file `file1'? n
rm: remove regular file `file2'? n
rm: remove regular file `file3'? n
rm: remove regular file `file4'? n
rm: remove regular file `file5'? n
rm: remove regular file `file6'? n
rm: remove regular file `file7'? n
oracle:~/adl/tmp> n
bash: n: command not found
oracle:~/adl/tmp> cd ..
oracle:~/adl> rm -f tmp/*
oracle:~/adl> ls -l tmp
total 0
oracle:~/adl>



On Fri, Oct 9, 2009 at 12:44 PM, Jared Still <jkstill@xxxxxxxxx> wrote:

> On Fri, Oct 9, 2009 at 10:16 AM, Fmhabash <fmhabash@xxxxxxxxx> wrote:
>
>> If I may add ...
>>  - I altered behavior of 'rm' cmd forcing it to be interactive needing
>> user confirmation. Scripts coded to use non-interactive version.
>>
>
> A trick to avoid accidentally deleting files you would rather keep.
>
> Create a file called '-i' in key directories.  This will force rm -f to go
> into interactive
> mode, as the '-i' filename is interpreted as an argument.
>
> Create '-i' file:  touch -- -i
>
> The double dash is used to tell rm (or any other *nix command) that the
> following stuff on the command line is not a command line option.
>
> Remove the file:  rm -- -i
>
> Create a tmp directory, copy a few files into it, and try it.
>
> It has saved me at least once.
>
>
> Jared Still
> Certifiable Oracle DBA and Part Time Perl Evangelist
> Oracle Blog: http://jkstill.blogspot.com
> Home Page: http://jaredstill.com
>
>

--
//www.freelists.org/webpage/oracle-l


Other related posts: