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

# msed(1)

manipulate message headers

## NAME

**msed** – manipulate message headers

## SYNOPSIS

**msed** *script* \[*msgs ...*\]

## DESCRIPTION

**msed** prints the messages *msgs* with message headers transformed by the commands in *script*.( See [mmsg(7)](/mmsg/7.md) for the message argument syntax.) If no *msgs* are passed, **msed** will default to the current message.

**msed** scripts are akin to a subset of [sed(1)](/sed/1.md) scripts, but optimized for modifying messages. Note that **msed** unfolds and normalizes message headers, so they may need to be passed through mmime(7) to ensure RFC 5322 conformance. The message body is not affected.

**msed** supports the following commands. The separators *after* the command letter may be substituted with an arbitrary symbol, just as in [sed(1)](/sed/1.md). Multiple commands can be separated by ‘**;**’.

- **/***header***/****a****/***value***/**

  If the header ‘*header***:**’ is not set in the message, add it with the given *value*.

- **/***headers***/****c****/***value***/**

  Change colon-separated headers matching the regular expression *headers*, with implicit anchoring to the header name, to the value given in *value*.

- **/***headers***/****d**

  Delete colon-separated headers matching the regular expression *headers*, with implicit anchoring to the header name. Use explicit ‘.\*’ to match arbitrary strings at the beginning or end of the headers.

  For example, ‘/x-.\*/d’ will delete all headers starting with ‘X-’ (always case insensitive), and ‘/from:to:cc/d’ will delete the headers ‘From:’, ‘To:’, and ‘Cc:’.

- \[**/***headers***/**\]**s****/***regex***/***replacement***/**\[*flags*\]

  Substitute matches of the POSIX Basic Regular Expression *regex* in headers matching the POSIX Basic Regular Expression *headers*, with implicit anchoring to the header name (or all headers, if omitted), with the string *replacement*, expanding ‘**&**’ to the matched string, and ‘**\\***N*’ to the*N* th sub-expression, where *N* is between 1 and 9.

  If *flags* contains the letter ‘**d**’, the header is removed if *regex* matched.

  By default, only the first match is replaced, unless *flags* contains the letter ‘**g**’.

  By default, *regex* is matched case sensitively, unless *flags* contains the letter ‘**i**’.

## EXIT STATUS

The **msed** utility exits 0 on success, and \>0 if an error occurs.

## SEE ALSO

[sed(1)](/sed/1.md), [mhdr(1)](/mhdr/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*⟩

## LICENSE

**msed** 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/**
