Cuz I’m smart like that…

find /var/mail/vhosts/ -type d | grep -P "\/var\/mail\/vhosts\/[a-z0-9\-\_]+\.[a-z]+\/[a-z\.]+$”

Finds just what I need… what a rPITA.

—
Ryan


> On Oct 22, 2015, at 9:09 AM, Ryan Coleman <ryan.coleman at cwis.biz> wrote:
> 
> I have my spam-learning script which runs against all the folders that meet a criteria… however the parent directories share the same style…
> 
> So what I have is…
> 
> /var/mail/vhosts/domain.ltd/first.lastname/.folders{…}
> 
> The scan I have search for .Spam.New and .Spam.Suspected and runs those…
> 
> but I would like to scan through the entire structure and grab each first.lastname folder (it would be the *2nd* level of my scan as I have a half-dozen domains and will add more soon)…
> 
> That point behind it is I can scan specific folders as SPAM and any other folders (other than Inbox, Sent and Trash) as HAM.
> 
> So here’s my folder for this specific email address (cwis.biz <http://cwis.biz/>):
> drwxrws---  5 vmail spamd   4096 Oct 22 09:07 .Drafts
> -rwxrwx---  1 vmail spamd      0 Jan 21  2015 maildirfolder
> drwxrws---  5 vmail spamd   4096 Mar 19  2015 .Mailing Lists
> drwxrws---  5 vmail spamd   4096 Oct 22 05:49 .Mailing Lists.MySQL
> drwxrws---  5 vmail spamd   4096 Oct 15 16:44 .Mailing Lists.Nextdoor
> drwxrws---  5 vmail spamd   4096 Oct 17 09:38 .Mailing Lists.PFSense
> drwxrws---  5 vmail spamd   4096 Oct 22 07:38 .Mailing Lists.spamassassin
> drwxrws---  5 vmail spamd   4096 Oct 21 14:25 .Mailing Lists.TCLUG
> drwxrws---  5 vmail spamd   4096 Oct 21 12:59 .Mailing Lists.TCPHP
> drwxrws---  2 vmail spamd  16384 Oct 22 09:06 new
> drwxrws---  5 vmail spamd   4096 Jan 21  2015 .Notes
> drwxrws---  5 vmail spamd   4096 Oct 21 22:34 .Sent Messages
> drwxrws---  3 vmail spamd   4096 Oct 15 17:02 sieve
> drwxrws---  5 vmail spamd   4096 Oct 22 07:19 .Spam.New
> drwxrws---  5 vmail spamd   4096 Oct 22 07:25 .Spam.Scanned
> drwxrws---  5 vmail spamd   4096 Oct 22 09:06 .Spam.Suspected
> drwxrws---  5 vmail spamd   4096 Oct 22 09:06 .Spam.Tagged
> -rwxrwx---  1 vmail spamd    282 Oct 15 16:43 subscriptions
> drwxrws---  2 vmail spamd   4096 Oct 22 09:06 tmp
> drwxrws---  5 vmail spamd   4096 Oct 22 01:25 .Trash
> 
> Basically I want to get any folder that starts with “." inside of /var/mail/vhosts/cwis.biz/ryan.coleman/ <http://cwis.biz/ryan.coleman/>
> 
> And then run the following commands:
> 
> /usr/bin/find /var/mail/vhosts/ -name '*.Spam.New*' -type d -exec /usr/bin/sa-learn  --spam --progress {}* \;
> /usr/bin/find /var/mail/vhosts/ -name '*.Spam.Suspected*' -type d -exec /usr/bin/sa-learn --spam --progress {}* \;
> /bin/mv /var/mail/vhosts/cwis.biz/ryan.coleman/.Spam.New/cur/* <http://cwis.biz/ryan.coleman/.Spam.New/cur/*> /var/mail/vhosts/cwis.biz/ryan.coleman/.Spam.Scanned/cur/ <http://cwis.biz/ryan.coleman/.Spam.Scanned/cur/>
> /bin/mv /var/mail/vhosts/cwis.biz/ryan.coleman/.Spam.New/new/* <http://cwis.biz/ryan.coleman/.Spam.New/new/*> /var/mail/vhosts/cwis.biz/ryan.coleman/.Spam.Scanned/cur/ <http://cwis.biz/ryan.coleman/.Spam.Scanned/cur/>
> 
> My regex-foo is not very good. I know there’s a way to do that with find(1) but I wouldn’t be able to wrap my head around it anyway.
> 
> TIA!
> 
>> Ryan
> _______________________________________________
> TCLUG Mailing List - Minneapolis/St. Paul, Minnesota
> tclug-list at mn-linux.org
> http://mailman.mn-linux.org/mailman/listinfo/tclug-list

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.mn-linux.org/pipermail/tclug-list/attachments/20151022/ae17ce68/attachment.html>