Created
August 7, 2010 09:00
-
-
Save orymate/512605 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# -lt 1 ] | |
then | |
echo "Usage: rotate (rot|ar)" >&2 | |
exit 10 | |
fi | |
set -v | |
cd /home/maat/Maildir/ || exit 1 | |
archival () | |
{ | |
if [ "$1" = '' ] | |
then | |
olddir="old" | |
else | |
olddir="$1.old" | |
fi | |
if [ ! -d ".$olddir" ] | |
then | |
maildirmake -f "$olddir" . || exit 2 | |
fi | |
find ".$1/cur/" -ctime "+$2" -exec mv '{}' ".$olddir/cur/" ';' | |
} | |
case $1 in | |
rot) | |
archival bme.info2008 14 | |
archival bme.info2009 14 | |
archival bme.duma2008 14 | |
archival bme.iit 40 | |
archival '' 30 | |
;; | |
ar) | |
tar cj $(find -type d -name \*.old) > $(date +%Y%m%d).tar.bz2 \ | |
&& exit 7 | |
find -type d -name \*.old -print0 | xargs -0 rm -rf | |
;; | |
esac | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment