TELECOM Digest OnLine - Sorted: Re: Place the Blame on Me


Re: Place the Blame on Me


Ankur Shah (voipuser@optonline.net)
Mon, 10 Jan 2005 14:21:44 -0500

Steve Sobol wrote:

> Tony P. wrote:

>> [TELECOM Digest Editor's Note: Regards the Unix 'rm' command, I have
>> 'rm' aliased to 'rm -i', but then if there are a dozen files in some
>> obsolete directory I wish to erase in bulk with 'rm -f' I get in
>> trouble. I have been told before it is not a good idea to use an
>> established Unix command as part of an alias to something else. Friday
>> was a nightmare for me, and it wasn't even the 13th of the month. PAT]

> Pat:

> Seeing as how rm -f is so powerful -- especially the way I use it, rm
> -rf (recursive/delete subdirectories too, force deletion) -- I try to
> remember to pause and examine the command line to make sure I'm
> deleting the right directory(ies).

> In my case, since I run my own Linux server and babysit a couple
> others, and am logged in as the 'superuser', I can very easily delete
> everything on the drive with one command, so I try to be extra careful
> even when not logged in as superuser. :)

> Hope this helps.

[snip]

Having gone through a similar, rather gruesome exercise of mistakenly
deleting data with no backups back in my early *nix days, I ended up
creating a "pseudo-backup" utility of my own. FWIW, here's how it
works:

<POC>

$type rm

rm is hashed (/export/home/ashah/bin/rm)

$cat /export/home/ashah/bin/rm
#!/bin/bash
##
# A simple shell wrapper for /bin/rm. It moves the data over
# to $TRASH_DIR to be recovered later, if need be.
#
# TODO: create a cronjob that would remove data from
# $TRASH_DIR older than a specified number of days.
#
# $comments > root [at] ankurshah [dot] net
##
TRASH_DIR="/data/backup/.$LOGNAME.trash"
CP=/bin/cp
RM=/bin/rm

[ ! -d "$TRASH_DIR" ] && mkdir $TRASH_DIR

$CP -r $* $TRASH_DIR >/dev/null 2>&1
$RM -r $*

</POC>

It is not even close to a complete backup solution and by no means
should be treated as one. It has come in handy for me at times, YMMV.

Regards,

-- Ankur

Post Followup Article Use your browser's quoting feature to quote article into reply
Go to Next message: Bill Matern: "Re: Place the Blame on Me"
Go to Previous message: NOTvalid@surplus4actors.INFO: "Re: Calling Canada is an International Call?"
May be in reply to: Lisa Minter: "Place the Blame on Me"
Next in thread: Bill Matern: "Re: Place the Blame on Me"
TELECOM Digest: Home Page