-1

我正在设置一个脚本来从 maildir 文件夹“.LearnAsSpam”中学习垃圾邮件

了解垃圾邮件后,我想将所有垃圾邮件移至所有用户的“.Junk”文件夹:

IE:

  • /home/vmail/domain1/ user1 /Maildir/.LearnAsSpam/cur/* -> /home/vmail/domain1/ user1 /Maildir/.Junk/cur/

  • /home/vmail/domain1/ user2 /Maildir/.LearnAsSpam/cur/* -> /home/vmail/domain1/ user2 /Maildir/.Junk/cur/

有没有一种简单的方法来编写一个 bash 脚本来正确匹配和移动每个用户的文件?

4

1 回答 1

0

好的,认为这会起作用:

find /home/vmail/ -type d -path "*/*/Maildir/.LearnAsSpam/cur" -exec sh -c '(cd {} && mv ./* ../../.Junk/cur)' ';'

以防万一有人感兴趣,垃圾邮件学习和移动垃圾邮件的整个脚本如下所示:

# do a spam check in LearnAsSpam and LearnAsHam folders
# find spam
sa-learn -p ~/.spamassassin/user_prefs --spam /home/vmail/*/*/Maildir/.LearnAsSpam/{cur,new}
# find ham
sa-learn -p ~/.spamassassin/user_prefs --ham /home/vmail/*/*/Maildir/.LearnAsHam/{cur,new}
# move spam
find /home/vmail/ -type d -path "*/*/Maildir/.LearnAsSpam/cur" -exec sh -c '(cd {} && mv ./* ../../.Junk/cur)' ';'
find /home/vmail/ -type d -path "*/*/Maildir/.LearnAsSpam/new" -exec sh -c '(cd {} && mv ./* ../../.Junk/new)' ';'
# move ham
find /home/vmail/ -type d -path "*/*/Maildir/.LearnAsHam/cur" -exec sh -c '(cd {} && mv ./* ../../.Inbox/cur)' ';'
find /home/vmail/ -type d -path "*/*/Maildir/.LearnAsHam/new" -exec sh -c '(cd {} && mv ./* ../../.Inbox/new)' ';' 

这已添加到 /etc/cron.daily/spamassassin 脚本中

于 2015-08-16T07:38:51.850 回答