tmaillist - scripts - various script and utils
(HTM) git clone git://z3bra.org/scripts
(DIR) Log
(DIR) Files
(DIR) Refs
---
tmaillist (816B)
---
1 #!/bin/sh
2
3 INBOX=$HOME/data/mail/inbox
4 MBASE=$HOME/data/mail
5 LISTS='crux lobsters pcc suckless'
6
7 crawl() {
8 # uses the X-BeenThere header set by maillist to check from
9 # which list a mail comes from
10 case $1 in
11 crux) REGEX='^X-BeenThere:.*crux@lists.crux.nu' ;;
12 lobsters) REGEX='^X-BeenThere:.*lobsters-[a-zA-Z0-9]*@lobste.rs' ;;
13 pcc) REGEX='^X-BeenThere:.*pcc@lists.ludd.ltu.se' ;;
14 suckless) REGEX='^X-Original-To:.*@suckless.org' ;;
15 esac
16
17 find $INBOX -type f -exec grep -liP "$REGEX" {} +
18 }
19
20 for ML in $LISTS; do
21 crawl "$ML" | while read FILE; do
22 printf '[1;37m%s[0m: %s\n' "$ML" "$(sed 's/^Subject: //p;d' $FILE)"
23 NEW=$(echo "$(basename $FILE)" | sed 's/\(:[12],[DFPR]*\)S\([T]*\)/\1\2/')
24 mv $FILE $MBASE/lists/$ML/new/$NEW
25 done
26 done