Re: major blunders

From: Jared Still <jkstill_at_gmail.com>
Date: Thu, 8 Oct 2009 09:31:40 -0700
Message-ID: <bf46380910080931n30421ecem3c0500d55b1e921c_at_mail.gmail.com>



Agreed.
For many years now I have used 'find' for recursive deletes, and verify the output of find before removing files.

Jared Still
Certifiable Oracle DBA and Part Time Perl Evangelist Oracle Blog: http://jkstill.blogspot.com Home Page: http://jaredstill.com

On Thu, Oct 8, 2009 at 4:51 AM, Mercadante, Thomas F (LABOR) < Thomas.Mercadante_at_labor.state.ny.us> wrote:

> How about:
>
>
>
> **Never** use rm rf ?
>
>
>
> I learned that lesson.
>
> I now go to the specific directory. Check twice to make sure Im there.
> And simply rm *.log or *.lis or *.trc
>
> Then back up a directory and use rmdir directory name.
>
>
>
> Rinse and repeat. This takes an extra 10 seconds.
>
>
>
> Rm r is very powerful and way too dangerous for me!
>
>
> Tom
>
>
>
> *From:* oracle-l-bounce_at_freelists.org [mailto:
> oracle-l-bounce_at_freelists.org] *On Behalf Of *Jared Still
> *Sent:* Wednesday, October 07, 2009 3:04 PM
> *To:* sims_at_suu.edu
> *Cc:* oracle-l_at_freelists.org
> *Subject:* Re: major blunders
>
>
>
> On Wed, Oct 7, 2009 at 8:41 AM, April Sims <sims_at_suu.edu> wrote:
>
> Compiling a list of major blunders to avoid:
>
> Don't use the number 8 for scripting or ORACLE_SID due to the wild card
> character * above it.
> Don't use rm *.*
>
>
>
> Here's a subtle variation on that.
>
>
>
> Say you wish to delete all *.lis files in a directory.
>
>
>
> The command would be "rm -f *.lis"
>
>
>
> The problem with the *. combination is that the * requires using the Shift
>
> key, and the . does not require the shift key.
>
>
>
> So, if your finger drags a little too long on the shift key, you end up
> with this:
>
>
>
> rm -f *>lis
>
>
>
> Can you guess what happens?
>
>
>
> Yes, you now have an directory with one empty file named "lis".
>
>
>
> A lesson learned long ago, and you can probably guess how I learned it.
>
>
>
> Fortunately, this lesson was learned well after the lesson on having
>
> good backups available...
>
>
>
> Another thing I make use of when running potentially dangerous commands
>
> such as rm: use ls first.
>
>
>
> Want to see what will be removed by rm -f *.txt?
>
>
>
> First run ls *.txt
>
>
>
> Then use command history and edit the command you just ran.
>
> This way you know the file specification is correct.
>
>
>
> Same for shell scripts written to do mass maintenance.
>
>
>
> Run it in 'dry run' mode before doing it for real.
>
>
>
> eg.
>
>
>
> for f in $( find . -name "stuff_i_do_not_want")
>
> do
>
> ls -ld $f
>
> # uncomment the rm when you are sure it is correct
>
> # rm $f
>
> done
>
>
> Jared Still
> Certifiable Oracle DBA and Part Time Perl Evangelist
> Oracle Blog: http://jkstill.blogspot.com
> Home Page: http://jaredstill.com
>
>
>
>
>

--
http://www.freelists.org/webpage/oracle-l
Received on Thu Oct 08 2009 - 11:31:40 CDT

Original text of this message