[prog] bash script

Kaitlyn Parkhurst kaitlyn at e-wire.org
Tue Apr 10 03:54:08 UTC 2007


If you have a lot of files that you'll be deleting you may want to replace
'-exec rm {} \;' with '-print0 | xargs -0 rm', this will make the process
less
CPU intensive as xargs will try to gather as many files as it can before
running rm ( where -exec will fork the process at each initeration over the
loop ) and in cases where you have massive amounts of files ( usually cases
where ls will not work ) using xargs and find tends to be one of the few
ways
that will work to delete the files.

On 4/9/07, Cynthia Kiser <cnk at ugcs.caltech.edu> wrote:
>
> Have your script run a find in the trash using the flags for mtime and
> then exec rm. Something like:
>
>         find ~/trash -mtime +7 -exec rm {} \;
>
> Please read and test before you replace "-print" with "-exec rm {} \;"
>
> Quoting Wolf Rising <wolfrising at gmail.com>:
> > I would like to run a little bash script at log out to empty any files
> > from the trash that are at least 7 days old. I can figure out how to
> > delete the trash at log out but not how to
> > set it to only delete files that are at least 7 days old. Could anyone
> toss
> > me
> > a hint or two? I was thinking find with a delete parameter might
> work....
> >
> > Thanks!!
> > _______________________________________________
> > Programming mailing list
> > Programming at linuxchix.org
> > http://linuxchix.org/mailman/listinfo/programming
>
> --
> Cynthia N. Kiser
>
> _______________________________________________
> Programming mailing list
> Programming at linuxchix.org
> http://linuxchix.org/mailman/listinfo/programming
>


More information about the Programming mailing list