Database Reference
In-Depth Information
#=================================================================
# Functions
# =================================================================
function CleanUpFiles {
# --------------------------------------------------------------------------------------------------
[ $WORKFILE ] && rm -f ${WORKFILE}
}
function TrimThisFile {
# --------------------------------------------------------------------------------------------------
if [ -d ${thisDIR} ]; then
if [ `find ${thisDIR} -name ${thisFILE} | wc -l` -gt 0 ]; then
NEW_FILE=${thisDIR}/${thisFILE}
OLD_FILE=${thisDIR}/${thisFILE}_old
LAST_DATE=`tail -1 ${NEW_FILE} | awk '{ print $1,$2,$3 }'`
echo "\nTrimming ${NEW_FILE}"
echo "Entries older than ${LAST_DATE} will be removed\n"
mv -f ${NEW_FILE} ${OLD_FILE}
cat ${OLD_FILE} | grep "${LAST_DATE}" >${NEW_FILE}
if [ `cat ${NEW_FILE} | wc -l` -gt 0 ]; then
rm -f ${OLD_FILE}
else
mv -f ${OLD_FILE} ${NEW_FILE}
fi
fi
echo "\n\n"
else
echo "\nDirectory ${thisDIR} not found\n\n"
fi
}
function SweepThese {
# --------------------------------------------------------------------------------------------------
if [ -d ${thisDIR} ]; then
find ${thisDIR} -name ${thisFILE} -mtime +${thisAGE} >${WORKFILE}
if [ `cat ${WORKFILE} | wc -l` -gt 0 ]; then
echo "\nCleaning up ${thisDIR} directory"
for thisTRASH in `cat ${WORKFILE}`; do
echo"\tRemoving ${thisTRASH}"
rm -f ${thisTRASH}
done
else
echo "\nNo files over ${thisAGE} days old matching"
echo "${thisDIR}/${thisFILE}"
fi
echo "\n\n"
else
echo "\nDirectory ${thisDIR} not found\n\n"
fi
}
Search WWH ::




Custom Search