NAME
grepmail - search mailboxes for mail matching a regular expression
SYNOPSIS
grepmail [-e <regex>] [-vihblr] [-d "datespec"] [mailbox ...]
DESCRIPTION
grepmail looks for mail messages containing a pattern, and prints the resulting messages on standard out.
By default grepmail looks in both header and body for the specified pattern.
When redirected to a file, the result is another mailbox, which can, in turn, be handled by standard User Agents, such as elm, or even used as input for another instance of grepmail.
The pattern is optional if -d is used, and must precede all flags unless it is specified using -e.
OPTIONS AND ARGUMENTS
Many of the options and arguments are analogous to those of grep.
- pattern
-
The pattern to search for in the mail message. May be any Perl regular expression, but should be quoted on the command line to protect against globbing (shell expansion).
- mailbox
-
Mailboxes must be traditional, UNIX
/bin/mail
mailbox format. The mailboxes may be zipped by gzip, in which case zcat must be installed on the system. If no mailbox is specified, takes input from stdin. - -b
-
Look only in the bodies of mail messages.
- -h
-
Look only in the headers of mail messages.
- -i
-
Make the search case-insensitive (by analogy to grep -i).
- -v
-
Invert the sense of the search, (by analogy to grep -v).
- -l
-
Output the names of files having an email matching the expression, (by analogy to grep -l).
- -r
-
Generate a report of the names of the files containing emails matching the expression, along with a count of the number of matching emails.
- -e
-
Explicitely specify the search pattern. This is useful for specifying patterns that begin with "-", which would otherwise be interpreted as a flag.
- -d
-
Date specifications must be of the form of: - a date like "today", "1st thursday in June 1992", "05/10/93", "12:30 Dec 12th 1880", "8:00pm december tenth", - OR "before", "after", or "since", followed by a date as defined above, - OR "between <date> and <date>", where <date> is defined as above.
EXAMPLES
Get all email that you mailed yesterday
grepmail -d yesterday sent-mail
Get all email that you mailed before the first thursday in June 1998 that pertains to research:
grepmail research -d "before 1st thursday in June 1992" sent-mail
Get all email you received since 8/20/98 that wasn't about research or your job, ignoring case:
grepmail "(research|job)" -i -d "since 8/20/98" -v saved-mail
Get all email about mime but not about Netscape:
grepmail mime -b saved-mail | grepmail Netscape -v
Print a list of all mailboxes containing a message from Rodney:
grepmail "^From.*Rodney" -h -l saved-mail*
Print a count of the number of messages about grepmail in all saved-mail mailboxes:
grepmail grepmail -b -r saved-mail*
AUTHOR
David Coppit, <coppit@cs.virginia.edu>,
http://www.cs.virginia.edu/~dwc3q/index.thml
SEE ALSO
elm(1), mail(1), grep(1), perl(1), printmail(1), Mail::Internet(3) Crocker, D. H., Standard for the Format of Arpa Internet Text Messages, RFC822.