[olug] Unix Tip: OOPS.. RM STAR

Thom Harrison id4spam at cox.net
Mon Apr 28 22:24:54 UTC 2003


Occasionally you'll need to clean up the recycle bin.
    rm /yourhomedir/recyclebin/*

-OR- maybe not, it seems to have called the alias. :-(

try
    /bin/rm /yourhomedir/recyclebin/*
instead to remove everything. ( Only one level deep ).  You'll need to run
    /bin/rm -rf /yourhomedir/recyclebin/*
to remove subdirectories and everything.

A MUCH BETTER SOLUTION:
-------------------------------------------
I'd suggest putting
    find /yourhomedir/recyclebin/ -mtime 7 -type f -exec /bin/rm {} \;
in your cron to clear out anything that's more than a week old.

*** Note the fully-qualified-name ( /bin/rm ) so that the alias isn't
called.

If you find that you're getting empty directories in the recyclebin you can
also run:
    find /yourhomedir/recyclebin/ -type d -exec /bin/rmdir {} \; 2>
/dev/null
from cron.  It won't remove non-empty directories ( the error msg is sent to
the bit bucket ).
It may take several iterations to clear out multiple levels of empty
subdirectories but it'll get there eventually.

I think I've got all the syntax right but I haven't verified it.

Thom

----- Original Message -----
From: "Andrew Holm-Hansen" <olug at einer.org>
To: "Omaha Linux User Group" <olug at olug.org>
Sent: Monday, April 28, 2003 2:02 PM
Subject: Re: [olug] Unix Tip: OOPS.. RM STAR


> pardon me if this is a repeat.  i broke my sendmail. :)
>
> alias rm='mv --target-directory=/yourhomedir/recylcebin'
>
> will work provided you have write access to the /yourhomedir/recyclebin
> directory (and that it exists).
>
> Andrew
>
> On Mon, 2003-04-28 at 12:09, Joe Catanzaro wrote:
> > I don't mean to sound like a windoze freak, but what about setting up an
> > alias that just moves stuff to a "recycle bin?" And then if you need to
> > recover it later, it's there. How would this be setup as an alias?
> >
> >
> > At 4/25/03 08:05 AM Friday, Dave Hull wrote:
> > >On Fri, 25 Apr 2003, Christopher Cashell wrote:
> > >
> > > > I take the middle road.  On my personal accounts, I dislike having
'rm'
> > > > aliased to 'rm -i'.  However, I think every root account should have
it
> > > > done.
> > > >
> > > > It's a simple matter of scope.  If, as a user, I accidentally run rm
*,
> > > > I can't hurt anyone but myself.  If it's my own system, it just
means I
> > > > need to restore a backup.  However, if you're using the root
account,
> > > > it's worth the inconvenience to make sure you don't screw things up.
> > >
> > >I agree completely. I should have been more specific. I always make
sure root
> > >has rm aliased to rm -i. If I want to override that at the command
line, I
> > >just use rm -rf.
> > >
> > >--
> > >Dave Hull
> > >http://insipid.com
> > >
> > >Suffering alone exists, none who suffer;
> > >The deed there is, but no doer thereof;
> > >Nirvana is, but no one is seeking it;
> > >The Path there is, but none who travel it.
> > >                 -- "Buddhist Symbolism", Symbols and Values
> > >
> > >_______________________________________________
> > >OLUG mailing list
> > >OLUG at olug.org
> > >http://lists.olug.org/mailman/listinfo/olug
> >
> >
> > Joe Catanzaro
> > joecatanzaro at cox.net
> >
> > _______________________________________________
> > OLUG mailing list
> > OLUG at olug.org
> > http://lists.olug.org/mailman/listinfo/olug
>
> _______________________________________________
> OLUG mailing list
> OLUG at olug.org
> http://lists.olug.org/mailman/listinfo/olug



More information about the OLUG mailing list