9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Skip Tavakkolian <9nut@9netics.com>
To: 9fans@9fans.net
Subject: Re: [9fans] Mg (Mail grep)
Date: Tue, 18 Nov 2008 21:16:01 -0800	[thread overview]
Message-ID: <1951d16c09d1e307e14011689af73b93@9netics.com> (raw)
In-Reply-To: <da559b1fa34b90d92605c884dd821039@9srv.net>

this is what i use:

cpue% cat bin/rc/mgrep
#! /bin/rc

if (test ($#* -lt 1) -o ($#* -gt 2)) {
	echo 'usage: mgrep [from] regex'
	exit
}

if (test ! -d /mail/fs/mbox) {
	echo '/mail/fs/mbox does not exist'
	exit
}

if (~ $#* 1) {
	grep $1 /mail/fs/mbox/*/body
	exit $?
}

for (i in `{grep $1 /mail/fs/mbox/*/from}) {
	d=`{basename -d $i}
	if (grep $2 $d/body) {
		echo $d
	}
}


also, i just looked at Mg. i'm not sure why i would do 'Mg foo bar
baz' when i can do grep '(foo|bar|baz)'

> 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).




  parent reply	other threads:[~2008-11-19  5:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-18 22:29 a
2008-11-18 22:54 ` erik quanstrom
2008-11-19  5:16 ` Skip Tavakkolian [this message]
2008-11-19 12:01   ` a
2008-11-19  6:00 ` akumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1951d16c09d1e307e14011689af73b93@9netics.com \
    --to=9nut@9netics.com \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).