Re: major blunders

From: Jared Still <jkstill_at_gmail.com>
Date: Wed, 7 Oct 2009 12:04:29 -0700
Message-ID: <bf46380910071204m79f69c3bl9b58d9d784c2fe58_at_mail.gmail.com>



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 Wed Oct 07 2009 - 14:04:29 CDT

Original text of this message