On Fri, Sep 16, 2005 at 04:50:52PM -0300, Eduardo Kienetz wrote:
Here's what I use (for reference):
cd /home/mydomain.com.br
for DIR in $(ls)
do
if [ -d $DIR/Maildir/.Sent/cur ] ; then
cd $DIR/Maildir/.Sent/cur
find . -type f -mtime +60 -exec rm {} \;
cd ../../../..
fi
if [ -d $DIR/Maildir/.Trash/cur ] ; then
cd $DIR/Maildir/.Trash/cur
find . -type f -mtime +15 -exec rm {} \;
cd ../../../..
fi
done
Thanks for posting that.
A couple of hints: you may find that the "for .. in .." construct fails if
ls returns a very large number of directories. You can avoid this problem by
using
ls | while read DIR
do
...
done
Your script will also break if any directory name contains spaces, but that
can be fixed by:
if [ -d "$DIR/Maildir/.Sent/cur" ]; then
cd "$DIR/Maildir/.Sent/cur"
although personally I would write
find "$DIR/Maildir/.Sent/cur" -type f ....
and drop the cd pair.
Regards,
Brian.