From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: To: 9fans@9fans.net Date: Tue, 18 Nov 2008 17:29:29 -0500 From: a@9srv.net MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: [9fans] Mg (Mail grep) Topicbox-Message-UUID: 481412dc-ead4-11e9-9d60-3106f5b1d025 A few days ago, someone in #plan9 asked how to search for all messages with a certain string in Acme Mail. The provided answer was "grep(1)", which has the advantage of being concise and maybe nominally correct, but the disadvantage of being totally useless as a practical answer. Today I found myself needing the same thing again, so I wrote Mg. I can't remember who wanted this, and it might be more widely useful, so I've put it at /n/sources/contrib/anothy/bin/rc/Mg. It's intended to be put in an Acme Mail tag line and invoked as Mg foo bar although all it really cares about is being run from within a /mail/fs/foo directory. For each argument, it will search the subject and body of every message in that mailbox and ask the plumber to open any matching messages. Right now it does no error checking, always folds case, checks body and subject always/only, has been only trivially tested, and I'm somewhat skeptical of the multipart handling, but it's already saved me more time than it took to write (which, except for the suspect multipart handling, was less than the time it took to write this note). Mg depends on Dan Cross' 'walk' (/n/sources/contrib/cross/walk.c).