summary refs log tree commit diff
path: root/man/msed.1
blob: 39f34f82e3848d367cfedbccc984e1e0229cf58b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
.Dd August 1, 2016
.Dt MSED 1
.Os
.Sh NAME
.Nm msed
.Nd stream editor for transforming mail
.Sh SYNOPSIS
.Nm
.Ar script
.Op Ar msgs\ ...
.Sh DESCRIPTION
.Nm
prints the messages
.Ar msgs
with mail headers transformed by the commands in
.Ar script .
See
.Xr mmsg 7
for the message argument syntax.
If no
.Ar msgs
are passed,
.Nm
will default to the current message.
.Pp
.Nm
scripts are akin to a subset of
.Xr sed 1
scripts, but optimized for modifying mail.
Note that
.Nm
unfolds and normalizes mail headers,
so they may need to be passed through
.Xr mmime 7
to ensure RFC 5322 conformance.
The mail body is copied as-is.
.Pp
.Nm
supports the following commands.
The separators
.Em after
the command letter may be substituted with an arbitrary symbol, just as in
.Xr sed 1 .
Multiple commands can be separated by
.Sq Cm \&; .
.Bl -tag -width Ds
.It Cm \&/ Ns Ar header Ns Cm \&/ Ns Ic a Ns Cm \&/ Ns Ar value Ns Cm \&/
If the header
.Sq Ar header Ns Cm \&:
is not set in the message, add it with given
.Ar value .
.It Cm \&/ Ns Ar headers Ns Cm \&/ Ns Ic c Ns Cm \&/ Ns Ar value Ns Cm \&/
Change colon-separated headers matching the regular expression
.Ar headers ,
with implicit anchoring to the header name,
to the value given in
.Ar value .
.It Cm \&/ Ns Ar headers Ns Cm \&/ Ns Ic d
Delete colon-separated headers matching the regular expression
.Ar headers ,
with implicit anchoring to the header name.
Use explicit
.Sq Li \&.*
to match arbitrary strings at the beginning or end of the headers.
.Pp
For example,
.Sq Li "/x-.*/d"
will delete all headers starting with
.Sq Li "X-"
(always case insensitive),
and
.Sq Li "/from:to:cc/d"
will delete the headers
.Sq Li From\&: ,
.Sq Li To\&: ,
and
.Sq Li Cc\&: .
.It Oo Cm \&/ Ns Ar headers Ns Cm \&/ Oc Ns Ic s Ns Cm \&/ Ns Ar regex Ns Cm \&/ Ns Ar replacement Ns Cm \&/ Ns Op Ar flags
Substitute matches of the POSIX Basic Regular Expression
.Ar regex
in headers matching the POSIX Basic Regular Expression
.Ar headers ,
with implicit anchoring to the header name
(or all headers, if omitted),
with the string
.Ar replacement ,
expanding
.Sq Cm \&&
to the matched string,
and
.Sq Cm \e Ns Ar N
to the
.Ar N Ns
th
sub-expression,
where
.Ar N
is between 1 and 9.
.Pp
If
.Ar flags
contains the letter
.Sq Cm d ,
the header is removed if
.Ar regex
matched.
.Pp
By default, only the first match is replaced, unless
.Ar flags
contains the letter
.Sq Cm g .
.Pp
By default,
.Ar regex
is matched case sensitively, unless
.Ar flags
contains the letter
.Sq Cm i .
.El
.Sh EXIT STATUS
.Ex -std
.Sh SEE ALSO
.Xr sed 1 ,
.Xr mmsg 7 ,
.Xr regex 7
.Sh AUTHORS
.An Leah Neukirchen Aq Mt leah@vuxu.org
.Sh LICENSE
.Nm
is in the public domain.
.Pp
To the extent possible under law,
the creator of this work
has waived all copyright and related or
neighboring rights to this work.
.Pp
.Lk http://creativecommons.org/publicdomain/zero/1.0/