.TH "MU FIND" "1" .SH "NAME" .PP \fBmu\d\s-2find\s+2\u\fP - find e-mail messages in the \fBmu\fP database. .SH "SYNOPSIS" .PP \fBmu [common-options] find [options] \fP .SH "DESCRIPTION" .PP \fBmu find\fP is the \fBmu\fP command for searching e-mail message that were stored earlier using \fBmu index(1)\fP. .SH "SEARCHING MAIL" .PP \fBmu find\fP starts a search for messages in the database that match some search pattern. The search patterns are described in detail in \fBmu-query(7)\fP. .PP For example: .RS .nf $ mu find subject:snow and date:2009.. .fi .RE .PP would find all messages in 2009 with 'snow' in the subject field, e.g: .RS .nf 2009-03-05 17:57:33 EET Lucia running in the snow 2009-03-05 18:38:24 EET Marius Re: running in the snow .fi .RE .PP Note, this the default, plain-text output, which is the default, so you don't have to use \fB--format=plain\fP. For other types of output (such as symlinks, XML or s-expressions), see the discussion in the \fBOPTIONS\fP-section below about \fB--format\fP. .PP The search pattern is taken as a command-line parameter. If the search parameter consists of multiple parts (as in the example) they are treated as if there were a logical \fBand\fP between them. .PP For details on the possible queries, see \fBmu-query(7)\fP. .SH "FIND OPTIONS" .PP Note, some of the important options are described in the *mu*(1) man-page and not here, as they apply to multiple mu-commands. .PP The \fBfind\fP-command has various options that influence the way \fBmu\fP displays the results. If you don't specify anything, the defaults are \fBfields="d f s"\fP, \fB--sortfield=date\fP and \fB--reverse\fP. .SS "-f, --fields=" .PP 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. .PP For example: .RS .nf $ mu find subject:snow --fields "d f s" .fi .RE .PP lists the date, subject and sender of all messages with 'snow' in the their subject. .PP The table of replacement characters is superset of the list mentions for search parameters, such as: .RS .nf t *t*o: recipient d Sent *d*ate of the message f Message sender (*f*rom:) g Message flags (fla*g*s) l Full path to the message (*l*ocation) s Message *s*ubject i Message-*i*d m *m*aildir .fi .RE .PP For the complate list, see \fBmu-fields(1)\fP. .PP The message flags are described in \fBmu-query(7)\fP. As an example, 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'. .SS "-s, --sortfield= and -z,--reverse" .PP specify the field to sort the search results by and the direction (i.e., 'reverse' means that the sort should be reverted - Z-A). Examples include: .RS .nf cc,c Cc (carbon-copy) recipient(s) date,d Message sent date from,f Message sender maildir,m Maildir msgid,i Message id prio,p Nessage priority subject,s Message subject to,t To:-recipient(s) .fi .RE .PP For the complete list use can use the \fBmu fields\fP command; see \fBmu-fields(1)\fP. .PP Thus, for example, to sort messages by date, you could specify: .RS .nf $ mu find fahrrad --fields "d f s" --sortfield=date --reverse .fi .RE .PP Note, if you specify a sortfield, by default, messages are sorted in reverse (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. .SS "-n, --maxnum=" .PP If > 0, display maximally that number of entries. If not specified, all matching entries are displayed. .SS "--summary-len=" .PP If > 0, use that number of lines of the message to provide a summary. .SS "--format=" .PP output results in the specified format: .IP \(em 4 The default is \fBplain\fP, i.e normal output with one line per message. .IP \(em 4 \fBlinks\fP outputs the results as a maildir with symbolic links to the found messages. This enables easy integration with mail-clients (see below for more information). .IP \(em 4 \fBxml\fP formats the search results as XML. .IP \(em 4 \fBsexp\fP formats the search results as an s-expression as used in Lisp programming environments. .IP \(em 4 \fBxquery\fP shows the Xapian query corresponding to your search terms. This is meant for for debugging purposes. .SS "--linksdir= and -c, --clearlinks" .PP when using \fB-format=links\fP, 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\fP will create the maildir if it does not exist yet. .PP If you specify \fB--clearlinks\fP, existing symlinks will be cleared from the target directories; this allows for re-use of the same maildir. However, this option will delete any symlink it finds, so be careful. .RS .nf $ mu find grolsch --format=links --linksdir=~/Maildir/search --clearlinks .fi .RE .PP stores links to found messages in \fI~/Maildir/search\fP. If the directory does not exist yet, it will be created. Note: when \fBmu\fP creates a Maildir for these links, it automatically inserts a \fI.noindex\fP file, to exclude the directory from \fBmu index\fP. .SS "--after=" .PP only show messages whose message files were last modified (\fBmtime\fP) after \fI\fP. \fI\fP is a UNIX \fBtime\d\s-2t\s+2\u\fP value, the number of seconds since 1970-01-01 (in UTC). .PP From the command line, you can use the \fBdate\fP command to get this value. For example, only consider messages modified (or created) in the last 5 minutes, you could specify .RS .nf --after=`date +%s --date='5 min ago'` .fi .RE .PP This is assuming the GNU \fBdate\fP command. .SS "--exec=" .PP the \fB--exec\fP coption causes the \fIcommand\fP to be executed on each matched message; for example, to see the raw text of all messages matching 'milkshake', you could use: .RS .nf $ mu find milkshake --exec='less' .fi .RE .PP which is roughly equivalent to: .RS .nf $ mu find milkshake --fields="l" | xargs less .fi .RE .SS "-b, --bookmark=" .PP use a bookmarked search query. Using this option, a query from your bookmark file will be prepended to other search queries. See \fBmu-bookmarks(5)\fP for the details of the bookmarks file. .SS "-u, --skip-dups" .PP whenever there are multiple messages with the same message-id field, only show the first one. This is useful if you have copies of the same message, which is a common occurrence when using e.g. Gmail together with \fBofflineimap\fP. .SS "-r, --include-related" .PP include messages being referred to by the matched messages -- i.e.. include messages that are part of the same message thread as some matched messages. This is useful if you want Gmail-style 'conversations'. .SS "-t, --threads" .PP show messages in a 'threaded' format -- that is, with indentation and arrows showing the conversation threads in the list of matching messages. When using this, sorting is chronological (by date), based on the newest message in a thread. .PP Messages in the threaded list are indented based on the depth in the discussion, and are prefix with a kind of arrow with thread-related information about the message, as in the following table: .RS .nf | | normal | orphan | duplicate | |-------------+--------+--------+-----------| | first child | `-> | `*> | `=> | | other | |-> | |*> | |=> | .fi .RE .PP Here, an 'orphan' is a message without a parent message (in the list of matches), and a duplicate is a message whose message-id was already seen before; not this may not really be the same message, if the message-id was copied. .PP The algorithm used for determining the threads is based on Jamie Zawinksi's description: \fIhttp://www.jwz.org/doc/threading.html\fP .SS "--muhome" .PP use a non-default directory to store and read the database, write the logs, etc. By default, \fBmu\fP uses the XDG Base Directory Specification (e.g. on GNU/Linux this defaults to \fI~/.cache/mu\fP and \fI~/.config/mu\fP). Earlier versions of \fBmu\fP defaulted to \fI~/.mu\fP, which now requires \fI\-\-muhome=~/.mu\fP. .PP The environment variable \fBMUHOME\fP can be used as an alternative to \fB--muhome\fP. The latter has precedence. .SH "COMMON OPTIONS" .SS "-d, --debug" .PP makes mu generate extra debug information, useful for debugging the program itself. By default, debug information goes to the log file, ~/.cache/mu/mu.log. It can safely be deleted when mu is not running. When running with --debug option, the log file can grow rather quickly. See the note on logging below. .SS "-q, --quiet" .PP causes mu not to output informational messages and progress information to standard output, but only to the log file. Error messages will still be sent to standard error. Note that mu index is much faster with --quiet, so it is recommended you use this option when using mu from scripts etc. .SS "--log-stderr" .PP causes mu to not output log messages to standard error, in addition to sending them to the log file. .SS "--nocolor" .PP do not use ANSI colors. The environment variable \fBNO\d\s-2COLOR\s+2\u\fP can be used as an alternative to \fB--nocolor\fP. .SS "-V, --version" .PP prints mu version and copyright information. .SS "-h, --help" .PP lists the various command line options. .SH "Integrating mu find with mail clients" .SS "\fBmutt\fP" .PP For \fBmutt\fP you can use the following in your \fImuttrc\fP; pressing the F8 key will start a search, and F9 will take you to the results. .RS .nf # mutt macros for mu macro index "mu find --clearlinks --format=links --linksdir=~/Maildir/search " \\ "mu find" macro index "~/Maildir/search" \\ "mu find results" .fi .RE .SS "\fBWanderlust\fP" .PP \fBSam B\fP suggested the following on the \fBmu\fP-mailing list. First add the following to your Wanderlust configuration file: .RS .nf (require 'elmo-search) (elmo-search-register-engine 'mu 'local-file :prog "/usr/local/bin/mu" ;; or wherever you've installed it :args '("find" pattern "--fields" "l") :charset 'utf-8) (setq elmo-search-default-engine 'mu) ;; for when you type "g" in folder or summary. (setq wl-default-spec "[") .fi .RE .PP Now, you can search using the \fBg\fP key binding; you can also create permanent virtual folders when the messages matching some expression by adding something like the following to your \fIfolders\fP file. .RS .nf VFolders { [date:today..now]!mu "Today" [size:1m..100m]!mu "Big" [flag:unread]!mu "Unread" } .fi .RE .PP After restarting Wanderlust, the virtual folders should appear. .SH "ENCODING" .PP \fBmu find\fP output is encoded according the locale for \fI\-\-format=plain\fP (the default), and UTF-8 for all other formats (\fIsexp\fP, \fIxml\fP). .SH "EXIT CODE" .PP This command returns 0 upon successful completion, or a non-zero exit code otherwise. Typical values are 2 (no matches found), 11 (database schema mismatch) and 12 (failed to acquire database lock). .SS "no matches found (2)" .PP Nothing matching found; try a different query .SS "database schema mismatch (11)" .PP You need to re-initialize \fBmu\fP, see \fBmu-init(1)\fP .SS "failed to acquire lock (19)" .PP Some other program has exclusive access to the mu (Xapian) database .SH "REPORTING BUGS" .PP Please report bugs at \fIhttps://github.com/djcb/mu/issues\fP. .SH "AUTHOR" .PP Dirk-Jan C. Binnema .SH "COPYRIGHT" .PP This manpage is part of \fBmu\fP 1.10.8. .PP Copyright © 2022-2023 Dirk-Jan C. Binnema. License GPLv3+: GNU GPL version 3 or later \fIhttps://gnu.org/licenses/gpl.html\fP. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. .SH "SEE ALSO" .PP \fBmu(1)\fP, \fBmu-index(1)\fP, \fBmu-query(7)\fP, \fBmu-fields(1)\fP