[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: scripting question




On Wed, 16 Apr 2003, Antony Gelberg wrote:

- several dozen/hundred ways to skin this cat ..
 
> ----- Original Message -----
> From: "Scott Henson" <debian-list@silvercoin.dyndns.org>
> To: <debian-user@lists.debian.org>
> Sent: Wednesday, April 16, 2003 2:13 AM
> Subject: Re: scripting question
> 
> 
> > On Tue, 2003-04-15 at 20:40, nate wrote:
> > > rm -rf *
...
> > happened cause yours will be hosed.  This command will generally delete
> > your entire file system.

only if you didn't do the proper testing first
 
> Well generally it depends what directory you execute it from.  But I agree
> that it is a risky policy.

one learns(best) and remembers(forever) when things are done the hard
way ... 

you're not a tried and true sysadmin till you've recovered from an
inadvertant equivalent of "rm -rf *" in the wrong directory :-)

> FWIW, I thought of rm -rf `ls |grep -v ?B?` but didn't know the regexp for
> start and end of word (the ?'s)...

start and end ...  ^B$   or  /B/  is easier... no need to get too fancy

	but it assumes certain directory  for ^B$ to work as expected
	which may or may not be what you really wanted

the more ` * & $ ' \ one uses, the more likely it is that a simple 
process/proceedure will get inadvertantly forgotten and you've got a mess
for testing your backup methodologies in a "raging fire situation"

-- in a script ... always check the success or failure of mv and cp before
   doing rm -f of anything ...  and test it on sample directory trees
	/path/to.testing.only/{a,b,c,d/d1,d/d2,d/d3}

-- test your scripts .. before using it on a live system ...

-- and be careful, that what you type on a command line will NOT
   necessarily work in a bash script

	root#  ls -la /home/foo  | grep -iv "ignore|this|and|that" 

	will need to be 'escaped' in some scripts and not others

c ya
alvin



Reply to: