exit 1
fi
- if [[ $2 ]]; then
- FILE_PATTERN="${MAIL_ARCHIVE_DIR}/${2}/*/*gz"
- SIZE=$(\dus ${MAIL_ARCHIVE_DIR}/${2} | cut -f 1 -d" ")
+ shift
+
+ HEADER_ONLY="-H"
+
+ if [[ $1 == "--body" ]]; then
+ HEADER_ONLY=""
+ shift
+ fi
+
+ if [[ $1 ]]; then
+ FILE_PATTERN="${MAIL_ARCHIVE_DIR}/${1}/*/*"
+ SIZE=$(\dus ${MAIL_ARCHIVE_DIR}/${1} | cut -f 1 -d" ")
else
- FILE_PATTERN="${MAIL_ARCHIVE_DIR}/*/*/*gz"
+ FILE_PATTERN="${MAIL_ARCHIVE_DIR}/*/*/*"
SIZE=$(\dus ${MAIL_ARCHIVE_DIR}/ | cut -f 1 -d" ")
fi
cat ${FILE_PATTERN} \
| pv -s ${SIZE} -p -t -e - \
- | zcat \
- | mboxgrep -i "$1" \
- | mboxgrep -v '^Subject:.*SPAM' > ${RESULT_MBOX}
+ | mboxgrep ${HEADER_ONLY} -i "${PATTERN}" \
+ | mboxgrep ${HEADER_ONLY} -v '^Subject:.*SPAM' > ${RESULT_MBOX}
echo "Found "$(grep ^"From " ${RESULT_MBOX} | wc -l)" messages."
else