mu/man/mu-find.1

441 lines
12 KiB
Groff
Raw Normal View History

2010-11-12 20:00:03 +01:00
.TH MU FIND 1 "November 2010" "User Manuals"
.SH NAME
2010-11-25 22:14:20 +01:00
mu find \- find e-mail messages in the
.B mu
database
.SH SYNOPSIS
.B mu find [options] <search expression>
.SH DESCRIPTION
2010-11-25 22:14:20 +01:00
\fBmu find\fR is the \fBmu\fR sub-command for searching e-mail message that
were stored earlier using
\fBmu index(1)\bR.
2010-11-12 20:00:03 +01:00
.SH SEARCHING MAIL
2010-11-25 22:14:20 +01:00
\fBmu find\fR starts a search for messages in the database that match some
search pattern. For example:
.nf
$ mu find subject:snow from:john
.fi
would find all messages from John with 'snow' in the subject field.
2010-09-05 20:20:46 +02:00
The search pattern is taken as a command-line parameter. If the search
2010-11-25 22:14:20 +01:00
parameter consists of multiple parts (as in the example) they are treated as
if there were a logical \fBAND\fR between them.
If you want to make your own constructions (using \fBAND\fR, \fBOR\fR,
2010-09-05 20:20:46 +02:00
\fBNOT\fR etc., you have to put quotes around them so \fBmu\fR can consider
them as a unit; for example to find mails with oranges OR mandarins in the
2010-11-12 20:00:03 +01:00
subject-field, you can use:
2010-11-25 22:14:20 +01:00
2010-09-05 20:20:46 +02:00
.nf
2010-11-25 22:14:20 +01:00
$ mu find 'subject:orange OR subject:mandarin'
2010-09-05 20:20:46 +02:00
.fi
2010-11-12 20:00:03 +01:00
\fBmu\fR relies on the Xapian database for its searching capabilities, so it
offers all the search functionality that Xapian offers; for all the details,
see:
\fIhttp://xapian.org/docs/queryparser.html\fR
One special feature of \fBmu\fR is that is does not distinguish between
uppercase and lowercase, nor the accented or unaccented versions of
characters. All match. In general, \fBmu\fR tries to be 'eager' in matching,
as filtering out unwanted results is usually preferrable over non matching
messages.
In older versions of mu, queries were logged in \fI<mu-home>/mu.log\fR;
2010-11-25 22:14:20 +01:00
however, since version 0.9, mu no longer does this.
The basic way to search a message is to type some words matching it, as you
would do in an internet search engine. For example,
.nf
2010-11-25 22:14:20 +01:00
$ mu find monkey banana
.fi
will find all messages that contain both 'monkey' and 'banana' in either body
or subject or one of the address-fields (to/from/cc).
Note that due to the way to Xapian query parser functions, the match with
e-mail addresses may fail, because Xapian handles characters like '@', '.' (as
seen in e-mail addresses) in a special way. However, you can match those still
if you an explicit search prefix; in other words, if, for example:
.nf
2010-11-25 22:14:20 +01:00
$ mu find foo@example.com
.fi
might not work, while
.nf
2010-11-25 22:14:20 +01:00
$ mu find f:foo@example.com
.fi
2010-11-25 22:14:20 +01:00
does.
As mentioned, matching is case-insensitive and accent-insensitive;
thus
2010-11-12 20:00:03 +01:00
.nf
2010-11-25 22:14:20 +01:00
$ mu find Mönkey BÄNAÑå
2010-11-12 20:00:03 +01:00
.fi
yields the same results as the example above.
\fBmu\fR also recognizes prefixes for specific fields in a messages; for
example:
.nf
2010-11-25 22:14:20 +01:00
$ mu find subject:penguin
.fi
to find messages with have the word \fBpenguin\fR in the subject field. You
can abbreviate \fBsubject:\fR to just \fBs:\fR. Here is the full table of the
search fields and their abbreviations:
.nf
cc,c CC (Carbon-Copy) recipient
from,f Message sender
subject,s Message subject
to,t To: recipient
maildir,m Maildir
msgid,i Message-ID
prio,p Message priority ('low', 'normal' or 'high')
flag,g Message Flags
date,d Date-Range
.fi
2010-11-12 20:00:03 +01:00
For clarity, this man-page uses the longer versions.
The meaning of most of these fields should be clear, but some require some
extra discusion.
First, the message flags field describes certain properties of the message, as
listed in the following table:
.nf
2010-11-25 22:14:20 +01:00
d,draft Draft Message
f,flagged Flagged
n,new New message (in new/ Maildir)
p,passed Passed ('Handled')
r,replied Replied
s,seen Seen
t,thrashed Marked for deletion
a,attach Has attachment
z,signed Signed message
x,encrypted Encrypted message
.fi
Using this, we can search e.g. for all signed messages that have an
attachment:
2010-11-25 22:14:20 +01:00
.nf
2010-11-25 22:14:20 +01:00
$ mu find flag:signed flag:attach
.fi
The message-priority has three possible values: low, normal or high. We can
match them using 'prio' - for example, to get all high-priority messages with
a subject containing some bird:
.nf
2010-11-25 22:14:20 +01:00
$ mu find prio:high subject:nightingale
.fi
The Maildir field describes the directory path starting \fBafter\fR the
Maildir-base path, and before the \fI/cur/\fR or \fI/new/\fR part. So for
example, if there's a message with the file name
\fI~/Maildir/lists/running/cur/1234.213:2,\fR, you could find it (and all the
other messages in the same maildir) with:
2010-11-12 20:00:03 +01:00
.nf
2010-11-25 22:14:20 +01:00
$ mu find maildir:/lists/running
.fi
2010-11-12 20:00:03 +01:00
Note the starting '/'. If you want to match mails in the 'root' maildir, you
can do with a single '/':
2010-11-12 20:00:03 +01:00
.nf
2010-11-25 22:14:20 +01:00
$ mu find maildir:/
.fi
2010-11-12 20:00:03 +01:00
(and of course you can use the \fBm:\fR shortcut instead of \fBmaildir:\fR)
The date:/d: search parameter is 'special' in the fact that it takes a range
of dates. For now, these dates are in ISO 8601 format (YYYYMMDDHHMM); you can
leave out the right part, and mu will add the rest, depending on whether this
is the beginning or end of the date interval. For example, for the beginning
of the interval "201012" would be interpreted as "20101201010000", or December
1, 2010 at 00:00, while for the end of the interval, this would be interpreted
as "20101231122359", or December 31, 2010 at 23:59.
To get all messages between (inclusive) the 5th of May 2009 and the 2nd of
June 2010, you could use:
.nf
2010-11-25 22:14:20 +01:00
$ mu find date:20090505..20100602
.fi
Characters like ':', '/', '-' and single '.' are ignore, so the following is
equivalent but more readable:
.nf
2010-11-25 22:14:20 +01:00
$ mu find date:2009-05-05..2010-06-02
.fi
Precision is up to the minute and 24-hour notation for times is used, so
another example would be:
.nf
2010-11-25 22:14:20 +01:00
$ mu find date:2009-05-05/12:23..2010-06-02/17:18
.fi
An important point here is that the date matches are against local the local
time zone active the time when the mu database was filled (using \fBmu
index\fR).
\fBmu\fR also understand relative dates, in the form of a posiive number
followed by h (hour), d (day), w (week), m (30 days) or y (365 days). Some
examples will explain this:
2010-11-25 22:14:20 +01:00
.nf
2010-11-25 22:14:20 +01:00
5h five hours in the past
2w one week in the past
3m three times 30 days in the past
1y 365 days in the past
.fi
2010-11-25 22:14:20 +01:00
Using this notation, you can for example match messages between two and three
weeks old:
.nf
2010-11-25 22:14:20 +01:00
$ mu find date:3w..2w
.fi
Finally, there are some special keywords for dates, namely 'now', meaning the
prsent moment and 'today' for the beginning of today. So to get all messages
sent or received today, you could use:
.nf
2010-11-25 22:14:20 +01:00
$ mu find date:today..now
.fi
2010-11-12 20:00:03 +01:00
.SH OPTIONS
2010-11-12 20:00:03 +01:00
Note, some of the important options are described in the \fBmu(1)\fR man-page
and not here, as they apply to multiple mu-commands.
The \fBfind\fR-command has various options that influence the way \fBmu\fR
displays the results. If you don't specify anything, the defaults are
\fI\-\-fields="d f s"\fR, \fI\-\-sortfield=date\fR and \fI\-\-descending\fR.
.TP
\fB\-f\fR, \fB\-\-fields\fR=\fI<fields>\fR
specifies a string that determines which fields are shown in the output. This
string consists of a number of characters (such as 's' for subject or 'f' for
from), which will replace with the actual field in the output. Fields that are
not known will be output as-is, allowing for some simple formatting.
For example:
.nf
2010-11-25 22:14:20 +01:00
$ mu find subject:snow --fields "d f s"
.fi
would list the date, subject and sender of all messages with 'snow' in the
their subject.
The table of replacement characters is superset of the list mentions for
search parameters; the complete list:
.nf
t \fBt\fRo: recipient
c \fBc\fRc: (Carbon-Copy) recipient
d Sent \fBd\fRate of the message
f Message sender (\fBf\fRrom:)
g Message flags (fla\fBg\fRs)
l Full path to the message (\fBl\fRocation)
p Message \fBp\fRriority (high, normal, low)
s Message \fBs\fRubject
i Message-\fBi\fRd
m \fBm\fRaildir
.fi
The message flags are the same ones we already saw in the message flags
above. Thus, a message which is 'seen', has an attachment and is signed would
have 'asz' as its corresponding output string, while an encrypted new message
would have 'nx'.
.TP
\fB\-s\fR, \fB\-\-sortfield\fR \fR=\fI<field>\fR and \fB\-z\fR, \fB\-\-descending\fR
specifies the field to sort the search results by, and the direction. The
following fields are supported:
.nf
cc,c CC (Carbon-Copy) recipient
date,d message sent date
from,f message sender
maildir,m maildir
msgid,i message id
prio,p message priority
subject,s message subject
to,t To:-recipient
.fi
Thus, for example, to sort messages by date, you could specify:
.nf
$ mu find fahrrad --fields "d f s" --sortfield=date --descending
.fi
Note, if you specify a sortfield, by default, messages are sorted in
descending order (e.g., from lowest to highest). This is usually a good
choice, but for dates it may be more useful to sort in the opposite direction.
.TP
\fB\-\-xquery\fR
shows the Xapian query corresponding to your search terms. This is primarily
meant for for debugging purposes.
.TP
\fB\-k\fR, \fB\-\-summary\-len\fR=\fI<len>\fR
output a summary based on up to \fI\len\fR lines of the message. The default is
.B 0
, or no summary.
.TP
\fB\-\-linksdir\fR \fR=\fI<dir>\fR and \fB\-c\fR, \fB\-\-clearlinks\fR
output the results as a maildir with symbolic links to the found
messages. This enables easy integration with mail-clients (see below for more
information). \fBmu\fR will create the maildir if it does not exist yet.
If you specify \fB\-\-clearlinks\fR, all existing symlinks will be cleared
from the target maildir; this allows for re-use of the same directory. An
alternative would be to delete the target directory before, but this has a big
chance of accidentaly removing something that should not be removed.
.nf
$ mu find grolsch --linksdir=~/Maildir/search --clearlinks
.fi
will store links to found messages in \fI~/Maildir/search\fR. If the directory
does not exist yet, it will be created.
Note: when \fBmu\fR creates a Maildir for these links, it automatically
inserts a \fI.noindex\fR file, to exclude the directory from \fBmu
index\fR.
2010-11-13 16:29:20 +01:00
.TP
\fB\-b\fR, \fB\-\-bookmark\fR=\fI<bookmark>\fR
use a bookmarked search query. Using this option, a query from your bookmark
file will be prepended to other search queries. See mu-bookmarks(1) for the
details of the bookmarks file.
.SS Example queries
Here are some simple examples of \fBmu\fR search queries; you can make many
more complicated queries using various logical operators, parentheses and so
on, but in the author's experience, it's usually faster to find a message with
a simple query just searching for some words.
Find all messages with both 'bee' and 'bird' (in any field)
.nf
$ mu find 'bee AND bird'
.fi
or shorter, because \fBAND\fR is implied:
.nf
$ mu find bee bird
.fi
Find all messages with either Frodo or Sam:
.nf
$ mu find 'Frodo OR Sam'
.fi
Find all messages with the 'wombat' as subject, and 'capibara' anywhere:
.nf
$ mu find subject:wombat capibara
.fi
Find all messages in the 'Archive' folder from Fred:
.nf
2010-11-08 23:25:59 +01:00
$ mu find from:fred maildir:/Archive
.fi
Find all messages with attachments:
.nf
$ mu find flag:attach
.fi
.SS Integrating mu find with mail clients
.TP
\fBmutt\fR
For \fBmutt\fR you can use the following in your \fImuttrc\fR; pressing the F8
key will start a search, and F9 will take you to the results.
.nf
# mutt macros for mu
macro index <F8> "<shell-escape>mu find -c -l ~/Maildir/search " \
"mu find"
macro index <F9> "<change-folder-readonly>~/Maildir/search" \
"display mu find results"
.fi
.TP
\fBWanderlust\fR
2010-11-12 20:00:03 +01:00
If you use the Wanderlust e-mail client for \fBemacs\fR, the following
definitions can be used; typing 'Q' will start a query.
.nf
;; mu integration for Wanderlust
(defvar mu-wl-mu-program "mu")
(defvar mu-wl-search-folder "search")
(defun mu-wl-search ()
"search for messages with `mu', and jump to the results"
(interactive)
(let* ((muexpr (read-string "Find messages matching: "))
(sfldr (concat elmo-maildir-folder-path "/"
mu-wl-search-folder))
(cmdline (concat mu-wl-mu-program " find "
"--clearlinks --linksdir='" sfldr "' "
muexpr)))
(= 0 (shell-command cmdline))))
(defun mu-wl-search-and-goto ()
"search and jump to the folder with the results"
(interactive)
(if (mu-wl-search)
(wl-summary-goto-folder-subr
(concat "." mu-wl-search-folder)
'force-update nil nil t)
(message "Query failed")))
.fi
.SH BUGS
2010-09-05 20:20:46 +02:00
Please report bugs if you find them:
.BR http://code.google.com/p/mu0/issues/list
.SH AUTHOR
Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
.SH "SEE ALSO"
.BR mu(1)
.BR mu-index(1)