3 #########################################################################
4 # This program is free software: you can redistribute it and/or modify #
5 # it under the terms of the version 3 of the GNU General Public License #
6 # as published by the Free Software Foundation. #
8 # This program is distributed in the hope that it will be useful, but #
9 # WITHOUT ANY WARRANTY; without even the implied warranty of #
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
11 # General Public License for more details. #
13 # You should have received a copy of the GNU General Public License #
14 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
16 # Written by and Copyright (C) Francois Fleuret #
17 # Contact <francois.fleuret@idiap.ch> for comments & bug reports #
18 #########################################################################
22 RESULT_MBOX="/tmp/gma"
24 if [[ -z "${MAIL_ARCHIVE_DIR}" ]]; then
25 echo "Undefined \$MAIL_ARCHIVE_DIR" >&2
33 if [[ -z "${PATTERN}" ]]; then
34 echo "No pattern." >&2
39 FILE_PATTERN="${MAIL_ARCHIVE_DIR}/${2}/*/*gz"
40 SIZE=$(\dus ${MAIL_ARCHIVE_DIR}/${2} | cut -f 1 -d" ")
42 FILE_PATTERN="${MAIL_ARCHIVE_DIR}/*/*/*gz"
43 SIZE=$(\dus ${MAIL_ARCHIVE_DIR}/ | cut -f 1 -d" ")
46 echo "Looking for ${PATTERN}"
47 echo " in ${FILE_PATTERN}"
48 echo " writing result in ${RESULT_MBOX}"
51 | pv -s ${SIZE} -p -t -e - \
54 | mboxgrep -v '^Subject:.*SPAM' > ${RESULT_MBOX}
55 echo "Found "$(grep ^"From " ${RESULT_MBOX} | wc -l)" messages."