2011-02-23 15:39:35 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
a=60
|
|
|
|
n=
|
|
|
|
|
|
|
|
help() {
|
|
|
|
cat <<EOF
|
|
|
|
Usage: `basename "$0"` -h | [-i|-n] [-a AGE] DIR [DIR [...]]
|
|
|
|
Findet alle Dateien in DIR/archive, die zu alt sind und loescht sie.
|
|
|
|
-a Alter der Datei in Tagen (std: $a)
|
|
|
|
-i Fragt vorher nach (siehe rm)
|
|
|
|
-n Trockenlauf
|
|
|
|
EOF
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
|
2012-07-18 16:29:29 +02:00
|
|
|
while getopts hina: o
|
2011-02-23 15:39:35 +01:00
|
|
|
do
|
|
|
|
case "$o" in
|
2012-07-18 16:29:29 +02:00
|
|
|
-) break ;;
|
|
|
|
h) help ;;
|
|
|
|
a) a="$OPTARG" ; shift ;;
|
|
|
|
i) i=-i ;;
|
|
|
|
n) n=echo ;;
|
2011-02-23 15:39:35 +01:00
|
|
|
esac
|
|
|
|
done
|
2012-07-30 11:46:57 +02:00
|
|
|
shift `expr $OPTIND - 1`
|
2011-02-23 15:39:35 +01:00
|
|
|
|
|
|
|
[ 0 -lt $# ] || help
|
|
|
|
[ X = X"$a" ] || a="-mtime +$a"
|
|
|
|
|
|
|
|
for d
|
|
|
|
do
|
|
|
|
find "$d" -name archive -type d -exec sh -c '
|
|
|
|
find "$1" -type f '"$a"' -exec '"$n"' rm '"$i"' -- "{}" \;' -- '{}' \;
|
|
|
|
done
|