grepmail(1)
NAME
grepmail - search mailboxes for mail matching a regular
expression
SYNOPSIS
grepmail [--help|--version] [-abBDhHilmrRuvV] [-j status] [-s sizespec] [-d <date-specification>] [-X <signature-pattern>] [-Y <header-pattern>] [--] <files...> grepmail [--help|--version] [-abBDhHilmrRuvV] [-j status] [-s sizespec] [-d <date-specification>] [-X <signature-pattern>] [-Y <header-pattern>] [[-e] <pattern>] [--] <files...> grepmail [--help|--version] [-abBDhHilmrRuvV] [-j status] [-s sizespec] [-d <date-specification>] [-X <signature-pattern>] [-Y <header-pattern>] [-E <expr>] [--] <files...>
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 mail
box, which can, in turn, be handled by standard User
Agents, such as elm, or even used as input for another
instance of grepmail.
At least one of -E, -e, -d, -s, or -u must be specified.
The pattern is optional if -d, -s, and/or -u is used.
The -e flag is optional if there is no file whose name
is the pattern. The -E option can be used to specify
complex search expressions involving logical operators.
(See below.)
If a mailbox can not be found, grepmail searches the
$home/mail, $home/Mail, $home/Mailbox directories (or
the directory specified by the MAIL environment vari
able).
OPTIONS AND ARGUMENTS
Many of the options and arguments are analogous to those
of grep.
Arraywill find all emails which originate from coppit.org
(you must escape the "@" sign with a backslash), and
which contain the keyword "grepmail" anywhere in the
message, in any capitalization.
-E is incompatible with -b, -h, and -e. -i, -M, -S, and
-Y have not yet been implemented.
- Array(a stripped down version of "^FROM_DAEMON:"), which
should catch mails coming from most mailer-daemons. - --help
- Print a help message summarizing the usage.
- -
- All arguments following -- are treated as mail folders.
EXAMPLES
- ArrayGet all email about mime but not about Netscape. Constrain
the search to match the body, since most headers contain
the text "mime": - grepmail -b mime saved-mail | grepmail Netscape -v
- Print a list of all mailboxes containing a message from
Rodney. Constrain the search to the headers, since quoted
emails may match the pattern:
grepmail -hl "^From.*Rodney" saved-mail*- Find all emails with the text "Pilot" in both the header
and the body:
grepmail -hb "Pilot" saved-mail*- Print a count of the number of messages about grepmail in
all saved-mail mailboxes:
grepmail -br grepmail saved-mail*- Remove any duplicates from a mailbox:
grepmail -u saved-mail- Convert a Gnus mailbox to mbox format:
grepmail . gnus-mailbox-dir/* > mbox- Search for all emails to or from an address (taking into
account wrapped headers and different header names):
grepmail -Y '(^TO:|^From:)' my@email.address saved-mail- Find all emails from postmasters:
grepmail -Y '^FROM_MAILER:' . saved-mail
FILES
grepmail will not create temporary files while decompress
ing compressed archives. The last version to do this was
3.5. While the new design uses more memory, the code is
much simpler, and there is less chance that email can be
read by malicious third parties. Memory usage is deter
mined by the size of the largest email message in the
mailbox.
ENVIRONMENT
The MAIL environment variable can be used to specify the
default mail directory. This directory will be searched if
the specified mailbox can not be found directly.
BUGS AND LIMITATIONS
- Test case 1 fails on some platforms
- Bug not squashed yet. Any info would be appreciated.
- File names that look like flags cause problems.
- In some special circumstances, grepmail will be confused
by files whose names look like flags. In such cases, use
the -e flag to specify the search pattern.
AUTHOR
David Coppit, <david@coppit.org>, http://coppit.org/
SEE ALSO
- elm(1), mail(1), grep(1), perl(1), printmail(1),
Mail::Internet(3), procmailrc(5). Crocker, D. H., Stan
dard for the Format of Arpa Internet Text Messages,
RFC822.