1 <h1>NOTMUCH-SEARCH(1)</h1>
5 notmuch-search - search for messages matching the given search terms
10 <b>notmuch</b> <b>search</b> [<u>option</u> ...] <<u>search-term</u>> ...
15 Search for messages matching the given search terms, and display as re‐
16 sults the threads containing the matched messages.
18 The output consists of one line per thread, giving a thread ID, the
19 date of the newest (or oldest, depending on the sort option) matched
20 message in the thread, the number of matched messages and total mes‐
21 sages in the thread, the names of all participants in the thread, and
22 the subject of the newest (or oldest) message.
24 See <a href='../notmuch-search-terms-7/'>notmuch-search-terms</a>(7) for details of the supported syntax for
27 Supported options for <b>search</b> include
29 <b>--format=(json|sexp|text|text0)</b>
30 Presents the results in either JSON, S-Expressions, newline
31 character separated plain-text (default), or null character sep‐
32 arated plain-text (compatible with <b>xargs</b>(1) -0 option where
35 <b>--format-version=N</b>
36 Use the specified structured output format version. This is in‐
37 tended for programs that invoke <a href='../notmuch-1/'>notmuch</a>(1) internally. If omit‐
38 ted, the latest supported version will be used.
40 <b>--output=(summary|threads|messages|files|tags)</b>
43 Output a summary of each thread with any message matching
44 the search terms. The summary includes the thread ID,
45 date, the number of messages in the thread (both the num‐
46 ber matched and the total number), the authors of the
47 thread and the subject. In the case where a thread con‐
48 tains multiple files for some messages, the total number
49 of files is printed in parentheses (see below for an ex‐
53 Output the thread IDs of all threads with any message
54 matching the search terms, either one per line (<b>--for-</b>
55 <b>mat=text</b>), separated by null characters (<b>--format=text0</b>),
56 as a JSON array (<b>--format=json</b>), or an S-Expression list
57 (<b>--format=sexp</b>).
60 Output the message IDs of all messages matching the
61 search terms, either one per line (<b>--format=text</b>), sepa‐
62 rated by null characters (<b>--format=text0</b>), as a JSON ar‐
63 ray (<b>--format=json</b>), or as an S-Expression list (<b>--for-</b>
66 <b>files</b> Output the filenames of all messages matching the search
67 terms, either one per line (<b>--format=text</b>), separated by
68 null characters (<b>--format=text0</b>), as a JSON array (<b>--for-</b>
69 <b>mat=json</b>), or as an S-Expression list (<b>--format=sexp</b>).
71 Note that each message may have multiple filenames asso‐
72 ciated with it. All of them are included in the output
73 (unless limited with the <b>--duplicate=N</b> option). This may
74 be particularly confusing for <b>folder:</b> or <b>path:</b> searches
75 in a specified directory, as the messages may have dupli‐
76 cates in other directories that are included in the out‐
77 put, although these files alone would not match the
80 <b>tags</b> Output all tags that appear on any message matching the
81 search terms, either one per line (<b>--format=text</b>), sepa‐
82 rated by null characters (<b>--format=text0</b>), as a JSON ar‐
83 ray (<b>--format=json</b>), or as an S-Expression list (<b>--for-</b>
86 <b>--sort=(newest-first|oldest-first)</b>
87 This option can be used to present results in either chronologi‐
88 cal order (<b>oldest-first</b>) or reverse chronological order (<b>new-</b>
91 Note: The thread order will be distinct between these two op‐
92 tions (beyond being simply reversed). When sorting by <b>old-</b>
93 <b>est-first</b> the threads will be sorted by the oldest message in
94 each thread, but when sorting by <b>newest-first</b> the threads will
95 be sorted by the newest message in each thread.
97 By default, results will be displayed in reverse chronological
98 order, (that is, the newest results will be displayed first).
101 Skip displaying the first N results. With the leading '-', start
102 at the Nth result from the end.
105 Limit the number of displayed results to N.
107 <b>--exclude=(true|false|all|flag)</b>
108 A message is called "excluded" if it matches at least one tag in
109 search.exclude_tags that does not appear explicitly in the
110 search terms. This option specifies whether to omit excluded
111 messages in the search process.
113 <b>true</b> <b>(default)</b>
114 Prevent excluded messages from matching the search terms.
116 <b>all</b> Additionally prevent excluded messages from appearing in
117 displayed results, in effect behaving as though the ex‐
118 cluded messages do not exist.
120 <b>false</b> Allow excluded messages to match search terms and appear
121 in displayed results. Excluded messages are still marked
122 in the relevant outputs.
124 <b>flag</b> Only has an effect when <b>--output=summary</b>. The output is
125 almost identical to <b>false</b>, but the "match count" is the
126 number of matching non-excluded messages in the thread,
127 rather than the number of matching messages.
130 For <b>--output=files</b>, output the Nth filename associated with each
131 message matching the query (N is 1-based). If N is greater than
132 the number of files associated with the message, don't print
135 For <b>--output=messages</b>, only output message IDs of messages
136 matching the search terms that have at least N filenames associ‐
139 Note that this option is orthogonal with the <b>folder:</b> search pre‐
140 fix. The prefix matches messages based on filenames. This option
141 filters filenames of the matching messages.
146 The following shows an example of the summary output format, with one
147 message having multiple filenames.
149 % notmuch search date:today.. and tag:bad-news
150 thread:0000000000063c10 Today [1/1] Some Persun; To the bone (bad-news inbox unread)
151 thread:0000000000063c25 Today [1/1(2)] Ann Other; Bears (bad-news inbox unread)
152 thread:0000000000063c00 Today [1/1] A Thurd; Bites, stings, sad feelings (bad-news unread)
157 This command supports the following special exit status codes
159 <b>20</b> The requested format version is too old.
161 <b>21</b> The requested format version is too new.
166 <a href='../notmuch-1/'>notmuch</a>(1), <a href='../notmuch-address-1/'>notmuch-address</a>(1) <a href='../notmuch-config-1/'>notmuch-config</a>(1), <a href='../notmuch-count-1/'>notmuch-count</a>(1),
167 <a href='../notmuch-dump-1/'>notmuch-dump</a>(1), <a href='../notmuch-hooks-5/'>notmuch-hooks</a>(5), <a href='../notmuch-insert-1/'>notmuch-insert</a>(1), <a href='../notmuch-new-1/'>notmuch-new</a>(1),
168 <a href='../notmuch-reply-1/'>notmuch-reply</a>(1), <a href='../notmuch-restore-1/'>notmuch-restore</a>(1), <a href='../notmuch-search-terms-7/'>notmuch-search-terms</a>(7), <a href='../notmuch-show-1/'>not‐</a>
169 <a href='../notmuch-show-1/'>much-show</a>(1), <a href='../notmuch-tag-1/'>notmuch-tag</a>(1)
174 Carl Worth and many others
179 2009-2022, Carl Worth and many others