1MU(FIND)                         User Manuals                         MU(FIND)
2
3
4

NAME

6       mu find - find e-mail messages in the mu database.
7
8

SYNOPSIS

10       mu find [options] <search expression>
11
12

DESCRIPTION

14       mu find is the mu command for searching e-mail message that were stored
15       earlier using mu index(1).
16
17

SEARCHING MAIL

19       mu find starts a search for messages in the database  that  match  some
20       search  pattern.  The  search  patterns  are described in detail in mu-
21       query(7).
22
23       For example:
24
25          $ mu find subject:snow and date:2009..
26
27       would find all messages in 2009 with 'snow' in the subject field, e.g:
28
29         2009-03-05 17:57:33 EET Lucia  <lucia@example.com> running in the snow
30         2009-03-05 18:38:24 EET Marius <marius@foobar.com> Re: running in the snow
31
32       Note, this the default, plain-text output, which is the default, so you
33       don't  have  to  use --format=plain. For other types of output (such as
34       symlinks, XML or s-expressions), see the discussion in the OPTIONS-sec‐
35       tion below about --format.
36
37       The  search pattern is taken as a command-line parameter. If the search
38       parameter consists of multiple parts  (as  in  the  example)  they  are
39       treated as if there were a logical and between them.
40
41       For details on the possible queries, see mu-query(7).
42
43

OPTIONS

45       Note, some of the important options are described in the mu(1) man-page
46       and not here, as they apply to multiple mu-commands.
47
48       The find-command has various options that influence the way mu displays
49       the   results.   If  you  don't  specify  anything,  the  defaults  are
50       --fields="d f s", --sortfield=date and --reverse.
51
52
53       -f, --fields=<fields>
54              specifies a string that determines which fields are shown in the
55              output.  This string consists of a number of characters (such as
56              's' for subject or 'f' for from), which will  replace  with  the
57              actual  field  in  the output. Fields that are not known will be
58              output as-is, allowing for some simple formatting.
59
60              For example:
61
62                $ mu find subject:snow --fields "d f s"
63
64              would list the date, subject and sender  of  all  messages  with
65              'snow' in the their subject.
66
67              The table of replacement characters is superset of the list men‐
68              tions for search parameters, such as:
69                   t       to: recipient
70                   d       Sent date of the message
71                   f       Message sender (from:)
72                   g       Message flags (flags)
73                   l       Full path to the message (location)
74                   s       Message subject
75                   i       Message-id
76                   m       maildir
77
78              For the complete, up-to-date list, see: mu-fields(1)
79
80              The message flags are described in mu-query(7). As an example, a
81              message  which  is 'seen', has an attachment and is signed would
82              have 'asz' as its corresponding  output  string,  while  an  en‐
83              crypted new message would have 'nx'.
84
85
86       -s, --sortfield =<field> and -z,
87              --reverse specifies the field to sort the search results by, and
88              the direction (i.e., 'reverse' means that the sort should be re‐
89              verted - Z-A). Examples include:
90
91                   cc,c            Cc (carbon-copy) recipient(s)
92                   date,d          Message sent date
93                   from,f          Message sender
94                   maildir,m       Maildir
95                   msgid,i         Message id
96                   prio,p          Nessage priority
97                   subject,s       Message subject
98                   to,t            To:-recipient(s)
99
100              For  the  complete  list use can use the mu fields command; see:
101              mu-fields(1)
102
103              Thus, for example, to sort messages by date, you could specify:
104
105                $ mu find fahrrad --fields "d f s" --sortfield=date --reverse
106
107              Note, if you specify  a  sortfield,  by  default,  messages  are
108              sorted in reverse (descending) order (e.g., from lowest to high‐
109              est). This is usually a good choice, but for  dates  it  may  be
110              more useful to sort in the opposite direction.
111
112
113       -n, --maxnum=<number>
114              If > 0, display maximally that number of entries.  If not speci‐
115              fied, all matching entries are displayed.
116
117
118       --summary-len=<number>
119              If > 0, use that number of lines of the  message  to  provide  a
120              summary.
121
122
123       --format=plain|links|xquery|xml|sexp
124              output results in the specified format.
125
126              The  default  is plain, i.e normal output with one line per mes‐
127              sage.
128
129              links outputs the results as a maildir with  symbolic  links  to
130              the  found  messages.  This  enables easy integration with mail-
131              clients (see below for more information).
132
133              xml formats the search results as XML.
134
135              sexp formats the search results as an s-expression  as  used  in
136              Lisp programming environments.
137
138              xquery  shows  the  Xapian  query  corresponding  to your search
139              terms. This is meant for for debugging purposes.
140
141
142       --linksdir =<dir> and -c, --clearlinks
143              output the results as a maildir with symbolic links to the found
144              messages.  This  enables easy integration with mail-clients (see
145              below for more information). mu will create the  maildir  if  it
146              does not exist yet.
147
148              If  you  specify  --clearlinks,  all  existing  symlinks will be
149              cleared from the target directories; this allows for  re-use  of
150              the  same  maildir. However, this option will delete any symlink
151              it finds, so be careful.
152
153                $ mu find grolsch --format=links --linksdir=~/Maildir/search --clearlinks
154
155              will store links to found messages in ~/Maildir/search.  If  the
156              directory does not exist yet, it will be created.
157
158              Note:  when  mu  creates a Maildir for these links, it automati‐
159              cally inserts a .noindex file, to exclude the directory from  mu
160              index.
161
162
163       --after=<timestamp> only show messages whose message files were
164              last  modified  (mtime) after <timestamp>. <timestamp> is a UNIX
165              time_t value, the number of seconds since 1970-01-01 (in UTC).
166
167              From the command line, you can use the date command to get  this
168              value. For example, only consider messages modified (or created)
169              in the last 5 minutes, you could specify
170                --after=`date +%s --date='5 min ago'`
171              This is assuming the GNU date command.
172
173
174
175       --exec=<command>
176              the --exec command causes the command to  be  executed  on  each
177              matched  message;  for  example, to see the raw text of all mes‐
178              sages matching 'milkshake', you could use:
179                $ mu find milkshake --exec='less'
180              which is roughly equivalent to:
181                $ mu find milkshake --fields="l" | xargs less
182
183
184
185       -b, --bookmark=<bookmark>
186              use a bookmarked search query. Using this option, a  query  from
187              your  bookmark  file  will be prepended to other search queries.
188              See mu-bookmarks(1) for the details of the bookmarks file.
189
190
191
192       --skip-dups,-u whenever there are multiple messages with the
193              same name, only show the first one. This is useful if  you  have
194              copies  of  the  same message, which is a common occurrence when
195              using e.g. Gmail together with offlineimap.
196
197
198       --include-related,-r also include messages being referred to by
199              the matched messages -- i.e.. include messages that are part  of
200              the same message thread as some matched messages. This is useful
201              if you want Gmail-style 'conversations'. Note, finding these re‐
202              lated messages make searches slower.
203
204
205       -t, --threads show messages in a 'threaded' format --
206              that  is,  with  indentation and arrows showing the conversation
207              threads in the list of matching messages. When using this, sort‐
208              ing is chronological (by date), based on the newest message in a
209              thread.
210
211              Messages in the threaded list are indented based on the depth in
212              the discussion, and are prefix with a kind of arrow with thread-
213              related information about the message, as in the  following  ta‐
214              ble:
215
216              |             | normal | orphan | duplicate |
217              |-------------+--------+--------+-----------|
218              | first child | `->    | `*>    | `=>       |
219              | other       | |->    | |*>    | |=>       |
220
221              Here,  an 'orphan' is a message without a parent message (in the
222              list of matches), and a duplicate is a message whose  message-id
223              was  already  seen  before;  not this may not really be the same
224              message, if the message-id was copied.
225
226              The algorithm used for determining the threads is based on Jamie
227              Zawinksi's description: http://www.jwz.org/doc/threading.html
228
229
230
231   Integrating mu find with mail clients
232       mutt
233
234              For  mutt you can use the following in your muttrc; pressing the
235              F8 key will start a search, and F9 will take you to the results.
236
237              # mutt macros for mu
238              macro index <F8> "<shell-escape>mu find --clearlinks --format=links --linksdir=~/Maildir/search " \
239                                       "mu find"
240              macro index <F9> "<change-folder-readonly>~/Maildir/search" \
241                                       "mu find results"
242
243
244
245
246       Wanderlust
247
248              Sam B suggested the following on the mu-mailing list. First  add
249              the following to your Wanderlust configuration file:
250
251              (require 'elmo-search)
252              (elmo-search-register-engine
253                  'mu 'local-file
254                  :prog "/usr/local/bin/mu" ;; or wherever you've installed it
255                  :args '("find" pattern "--fields" "l") :charset 'utf-8)
256
257              (setq elmo-search-default-engine 'mu)
258              ;; for when you type "g" in folder or summary.
259              (setq wl-default-spec "[")
260
261              Now, you can search using the g key binding; you can also create
262              permanent virtual folders when the messages  matching  some  ex‐
263              pression  by adding something like the following to your folders
264              file.
265
266              VFolders {
267                [date:today..now]!mu  "Today"
268
269                [size:1m..100m]!mu    "Big"
270
271                [flag:unread]!mu      "Unread"
272              }
273
274              After restarting Wanderlust, the virtual folders should appear.
275
276

RETURN VALUE

278       mu find returns 0 upon successful completion; if the  search  was  per‐
279       formed,  there  needs to be a least one match. Anything else leads to a
280       non-zero return value, for example:
281
282       | code | meaning                        |
283       |------+--------------------------------|
284       |    0 | ok                             |
285       |    1 | general error                  |
286       |    4 | no matches (for 'mu find')     |
287
288
289

ENCODING

291       mu find output is encoded according the locale for --format=plain  (the
292       default), and UTF-8 for all other formats (sexp, xml).
293
294
295

BUGS

297       Please  report bugs if you find them: https://github.com/djcb/mu/issues
298       If you have specific messages which are not matched  correctly,  please
299       attach them (appropriately censored if needed).
300
301

AUTHOR

303       Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
304
305

SEE ALSO

307       mu(1), mu-index(1), mu-query(7) mu-fields(1)
308
309
310
31129 April 2022                          1                              MU(FIND)
Impressum