---
name: "magrep"
section: "1"
platform: "linux"
package: "mblaze"
version: "1.1-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/magrep"
---

# magrep(1)

search messages matching a pattern

## NAME

**magrep** – search messages matching a pattern

## SYNOPSIS

**magrep** \[**-c** \| **-h** \| **-o** \| **-p** \| **-q** \| **-m** *max*\] \[**-v**\] \[**-i**\] \[**-l**\] \[**-a** \| **-d**\] *header***:***regex* \[*msgs ...*\]

## DESCRIPTION

**magrep** prints the names of files from the specified *msgs* if the value of *header* matches the POSIX Extended Regular Expression *regex*.( See [mmsg(7)](/mmsg/7.md) for the message argument syntax.)

If *header* is empty, **magrep** matches against the maildir flags of *msgs*.

If *header* is ‘**\***’, **magrep** searches for the pattern in any header.

If *header* is ‘**/**’, **magrep** searches any plain text parts of the *msgs* body.

If no *msgs* are specified and **magrep** is used interactively, the current sequence will be searched.

The options are as follows:

- **-a**

  Search for *regex* in RFC 2822 address *header* parts only.

- **-c**

  Only print a count of matching headers. If **-v** is specified, count non-matching headers instead.

- **-d**

  Decode the *header* according to RFC 2047 prior to searching.

- **-h**

  Like **-p** but do not print the file name.

- **-i**

  Match *regex* case insensitively.

- **-l**

  Only search a message until a match has been found.

- **-m** *max*

  Do not show more than *max* matches.

- **-o**

  Print each match only, not the entire line. This option is ignored if **-c**, **-q** or **-v** is specified.

- **-p**

  Print the filename, the header and the matching line for each of the matched *msgs*. If **-o** is specified each match is printed, instead of the matching line. This option is ignored if **-c**, **-q** or **-v** is specified.

- **-q**

  Quiet mode: do not print anything, quit as soon as possible.

- **-v**

  Invert the match; print (or count) all files where *regex* does not match.

## EXIT STATUS

The **magrep** utility exits 0 on success, 1 if no match was found and \>1 if an error occurs.

## SEE ALSO

[grep(1)](/grep/1.md), [mmsg(7)](/mmsg/7.md), [regex(7)](/regex/7.md) / [re\_format(7)](/re_format/7.md)

## AUTHORS

Leah Neukirchen ⟨*leah@vuxu.org*⟩

## TRIVIA

**magrep** is not called mgrep because many tools with this name already exist.

## LICENSE

**magrep** is in the public domain.

To the extent possible under law, the creator of this work has waived all copyright and related or neighboring rights to this work.

**http://creativecommons.org/publicdomain/zero/1.0/**
