.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.20)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings.  \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote.  \*(C+ will
.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
.    ds -- \(*W-
.    ds PI pi
.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
.    ds L" ""
.    ds R" ""
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds -- \|\(em\|
.    ds PI \(*p
.    ds L" ``
.    ds R" ''
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.ie \nF \{\
.    de IX
.    tm Index:\\$1\t\\n%\t"\\$2"
..
.    nr % 0
.    rr F
.\}
.el \{\
.    de IX
..
.\}
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
.    \" fudge factors for nroff and troff
.if n \{\
.    ds #H 0
.    ds #V .8m
.    ds #F .3m
.    ds #[ \f1
.    ds #] \fP
.\}
.if t \{\
.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
.    ds #V .6m
.    ds #F 0
.    ds #[ \&
.    ds #] \&
.\}
.    \" simple accents for nroff and troff
.if n \{\
.    ds ' \&
.    ds ` \&
.    ds ^ \&
.    ds , \&
.    ds ~ ~
.    ds /
.\}
.if t \{\
.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
.    \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
.    \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
.    \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
.    ds : e
.    ds 8 ss
.    ds o a
.    ds d- d\h'-1'\(ga
.    ds D- D\h'-1'\(hy
.    ds th \o'bp'
.    ds Th \o'LP'
.    ds ae ae
.    ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "S2P 1"
.TH S2P 1 "2026-05-13" "perl v5.16.3" "Perl Programmers Reference Guide"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
psed \- a stream editor
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 2
\&   psed [\-an] script [file ...]
\&   psed [\-an] [\-e script] [\-f script\-file] [file ...]
\&
\&   s2p  [\-an] [\-e script] [\-f script\-file]
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
A stream editor reads the input stream consisting of the specified files
(or standard input, if none are given), processes is line by line by
applying a script consisting of edit commands, and writes resulting lines
to standard output. The filename '\f(CW\*(C`\-\*(C'\fR' may be used to read standard input.
.PP
The edit script is composed from arguments of \fB\-e\fR options and
script-files, in the given order. A single script argument may be specified
as the first parameter.
.PP
If this program is invoked with the name \fIs2p\fR, it will act as a
sed-to-Perl translator. See \*(L"\s-1SED\s0 \s-1SCRIPT\s0 \s-1TRANSLATION\s0\*(R".
.PP
\&\fBsed\fR returns an exit code of 0 on success or >0 if an error occurred.
.SH "OPTIONS"
.IX Header "OPTIONS"
.IP "\fB\-a\fR" 4
.IX Item "-a"
A file specified as argument to the \fBw\fR edit command is by default
opened before input processing starts. Using \fB\-a\fR, opening of such
files is delayed until the first line is actually written to the file.
.IP "\fB\-e\fR \fIscript\fR" 4
.IX Item "-e script"
The editing commands defined by \fIscript\fR are appended to the script.
Multiple commands must be separated by newlines.
.IP "\fB\-f\fR \fIscript-file\fR" 4
.IX Item "-f script-file"
Editing commands from the specified \fIscript-file\fR are read and appended
to the script.
.IP "\fB\-n\fR" 4
.IX Item "-n"
By default, a line is written to standard output after the editing script
has been applied to it. The \fB\-n\fR option suppresses automatic printing.
.SH "COMMANDS"
.IX Header "COMMANDS"
\&\fBsed\fR command syntax is defined as
.PP
   [\fIaddress\fR[\fB,\fR\fIaddress\fR]][\fB!\fR]\fIfunction\fR[\fIargument\fR]
.PP
with whitespace being permitted before or after addresses, and between
the function character and the argument. The \fIaddress\fRes and the
address inverter (\f(CW\*(C`!\*(C'\fR) are used to restrict the application of a
command to the selected line(s) of input.
.PP
Each command must be on a line of its own, except where noted in
the synopses below.
.PP
The edit cycle performed on each input line consist of reading the line
(without its trailing newline character) into the \fIpattern space\fR,
applying the applicable commands of the edit script, writing the final
contents of the pattern space and a newline to the standard output.
A \fIhold space\fR is provided for saving the contents of the
pattern space for later use.
.SS "Addresses"
.IX Subsection "Addresses"
A sed address is either a line number or a pattern, which may be combined
arbitrarily to construct ranges. Lines are numbered across all input files.
.PP
Any address may be followed by an exclamation mark ('\f(CW\*(C`!\*(C'\fR'), selecting
all lines not matching that address.
.IP "\fInumber\fR" 4
.IX Item "number"
The line with the given number is selected.
.IP "\fB$\fR" 4
.IX Item "$"
A dollar sign (\f(CW\*(C`$\*(C'\fR) is the line number of the last line of the input stream.
.IP "\fB/\fR\fIregular expression\fR\fB/\fR" 4
.IX Item "/regular expression/"
A pattern address is a basic regular expression (see 
\&\*(L"\s-1BASIC\s0 \s-1REGULAR\s0 \s-1EXPRESSIONS\s0\*(R"), between the delimiting character \f(CW\*(C`/\*(C'\fR.
Any other character except \f(CW\*(C`\e\*(C'\fR or newline may be used to delimit a
pattern address when the initial delimiter is prefixed with a
backslash ('\f(CW\*(C`\e\*(C'\fR').
.PP
If no address is given, the command selects every line.
.PP
If one address is given, it selects the line (or lines) matching the
address.
.PP
Two addresses select a range that begins whenever the first address
matches, and ends (including that line) when the second address matches.
If the first (second) address is a matching pattern, the second 
address is not applied to the very same line to determine the end of
the range. Likewise, if the second address is a matching pattern, the
first address is not applied to the very same line to determine the
begin of another range. If both addresses are line numbers,
and the second line number is less than the first line number, then
only the first line is selected.
.SS "Functions"
.IX Subsection "Functions"
The maximum permitted number of addresses is indicated with each
function synopsis below.
.PP
The argument \fItext\fR consists of one or more lines following the command.
Embedded newlines in \fItext\fR must be preceded with a backslash.  Other
backslashes in \fItext\fR are deleted and the following character is taken
literally.
.IP "[1addr]\fBa\e\fR \fItext\fR" 4
.IX Item "[1addr]a text"
Write \fItext\fR (which must start on the line following the command)
to standard output immediately before reading the next line
of input, either by executing the \fBN\fR function or by beginning a new cycle.
.IP "[2addr]\fBb\fR [\fIlabel\fR]" 4
.IX Item "[2addr]b [label]"
Branch to the \fB:\fR function with the specified \fIlabel\fR. If no label
is given, branch to the end of the script.
.IP "[2addr]\fBc\e\fR \fItext\fR" 4
.IX Item "[2addr]c text"
The line, or range of lines, selected by the address is deleted. 
The \fItext\fR (which must start on the line following the command)
is written to standard output. With an address range, this occurs at
the end of the range.
.IP "[2addr]\fBd\fR" 4
.IX Item "[2addr]d"
Deletes the pattern space and starts the next cycle.
.IP "[2addr]\fBD\fR" 4
.IX Item "[2addr]D"
Deletes the pattern space through the first embedded newline or to the end.
If the pattern space becomes empty, a new cycle is started, otherwise
execution of the script is restarted.
.IP "[2addr]\fBg\fR" 4
.IX Item "[2addr]g"
Replace the contents of the pattern space with the hold space.
.IP "[2addr]\fBG\fR" 4
.IX Item "[2addr]G"
Append a newline and the contents of the hold space to the pattern space.
.IP "[2addr]\fBh\fR" 4
.IX Item "[2addr]h"
Replace the contents of the hold space with the pattern space.
.IP "[2addr]\fBH\fR" 4
.IX Item "[2addr]H"
Append a newline and the contents of the pattern space to the hold space.
.IP "[1addr]\fBi\e\fR \fItext\fR" 4
.IX Item "[1addr]i text"
Write the \fItext\fR (which must start on the line following the command)
to standard output.
.IP "[2addr]\fBl\fR" 4
.IX Item "[2addr]l"
Print the contents of the pattern space: non-printable characters are
shown in C\-style escaped form; long lines are split and have a trailing
^'\f(CW\*(C`\e\*(C'\fR' at the point of the split; the true end of a line is marked with
a '\f(CW\*(C`$\*(C'\fR'. Escapes are: '\ea', '\et', '\en', '\ef', '\er', '\ee' for
\&\s-1BEL\s0, \s-1HT\s0, \s-1LF\s0, \s-1FF\s0, \s-1CR\s0, \s-1ESC\s0, respectively, and '\e' followed by a three-digit
octal number for all other non-printable characters.
.IP "[2addr]\fBn\fR" 4
.IX Item "[2addr]n"
If automatic printing is enabled, write the pattern space to the standard
output. Replace the pattern space with the next line of input. If
there is no more input, processing is terminated.
.IP "[2addr]\fBN\fR" 4
.IX Item "[2addr]N"
Append a newline and the next line of input to the pattern space. If
there is no more input, processing is terminated.
.IP "[2addr]\fBp\fR" 4
.IX Item "[2addr]p"
Print the pattern space to the standard output. (Use the \fB\-n\fR option
to suppress automatic printing at the end of a cycle if you want to
avoid double printing of lines.)
.IP "[2addr]\fBP\fR" 4
.IX Item "[2addr]P"
Prints the pattern space through the first embedded newline or to the end.
.IP "[1addr]\fBq\fR" 4
.IX Item "[1addr]q"
Branch to the end of the script and quit without starting a new cycle.
.IP "[1addr]\fBr\fR \fIfile\fR" 4
.IX Item "[1addr]r file"
Copy the contents of the \fIfile\fR to standard output immediately before
the next attempt to read a line of input. Any error encountered while
reading \fIfile\fR is silently ignored.
.IP "[2addr]\fBs/\fR\fIregular expression\fR\fB/\fR\fIreplacement\fR\fB/\fR\fIflags\fR" 4
.IX Item "[2addr]s/regular expression/replacement/flags"
Substitute the \fIreplacement\fR string for the first substring in
the pattern space that matches the \fIregular expression\fR.
Any character other than backslash or newline can be used instead of a 
slash to delimit the regular expression and the replacement.
To use the delimiter as a literal character within the regular expression
and the replacement, precede the character by a backslash ('\f(CW\*(C`\e\*(C'\fR').
.Sp
Literal newlines may be embedded in the replacement string by
preceding a newline with a backslash.
.Sp
Within the replacement, an ampersand ('\f(CW\*(C`&\*(C'\fR') is replaced by the string
matching the regular expression. The strings '\f(CW\*(C`\e1\*(C'\fR' through '\f(CW\*(C`\e9\*(C'\fR' are
replaced by the corresponding subpattern (see \*(L"\s-1BASIC\s0 \s-1REGULAR\s0 \s-1EXPRESSIONS\s0\*(R").
To get a literal '\f(CW\*(C`&\*(C'\fR' or '\f(CW\*(C`\e\*(C'\fR' in the replacement text, precede it
by a backslash.
.Sp
The following \fIflags\fR modify the behaviour of the \fBs\fR command:
.RS 4
.IP "\fBg\fR" 8
.IX Item "g"
The replacement is performed for all matching, non-overlapping substrings
of the pattern space.
.IP "\fB1\fR..\fB9\fR" 8
.IX Item "1..9"
Replace only the n\-th matching substring of the pattern space.
.IP "\fBp\fR" 8
.IX Item "p"
If the substitution was made, print the new value of the pattern space.
.IP "\fBw\fR \fIfile\fR" 8
.IX Item "w file"
If the substitution was made, write the new value of the pattern space
to the specified file.
.RE
.RS 4
.RE
.IP "[2addr]\fBt\fR [\fIlabel\fR]" 4
.IX Item "[2addr]t [label]"
Branch to the \fB:\fR function with the specified \fIlabel\fR if any \fBs\fR
substitutions have been made since the most recent reading of an input line
or execution of a \fBt\fR function. If no label is given, branch to the end of
the script.
.IP "[2addr]\fBw\fR \fIfile\fR" 4
.IX Item "[2addr]w file"
The contents of the pattern space are written to the \fIfile\fR.
.IP "[2addr]\fBx\fR" 4
.IX Item "[2addr]x"
Swap the contents of the pattern space and the hold space.
.IP "[2addr]\fBy\fR\fB/\fR\fIstring1\fR\fB/\fR\fIstring2\fR\fB/\fR" 4
.IX Item "[2addr]y/string1/string2/"
In the pattern space, replace all characters occurring in \fIstring1\fR by the
character at the corresponding position in \fIstring2\fR. It is possible
to use any character (other than a backslash or newline) instead of a
slash to delimit the strings.  Within \fIstring1\fR and \fIstring2\fR, a
backslash followed by any character other than a newline is that literal
character, and a backslash followed by an 'n' is replaced by a newline
character.
.IP "[1addr]\fB=\fR" 4
.IX Item "[1addr]="
Prints the current line number on the standard output.
.IP "[0addr]\fB:\fR [\fIlabel\fR]" 4
.IX Item "[0addr]: [label]"
The command specifies the position of the \fIlabel\fR. It has no other effect.
.IP "[2addr]\fB{\fR [\fIcommand\fR]" 4
.IX Item "[2addr]{ [command]"
.PD 0
.IP "[0addr]\fB}\fR" 4
.IX Item "[0addr]}"
.PD
These two commands begin and end a command list. The first command may
be given on the same line as the opening \fB{\fR command. The commands
within the list are jointly selected by the address(es) given on the
\&\fB{\fR command (but may still have individual addresses).
.IP "[0addr]\fB#\fR [\fIcomment\fR]" 4
.IX Item "[0addr]# [comment]"
The entire line is ignored (treated as a comment). If, however, the first
two characters in the script are '\f(CW\*(C`#n\*(C'\fR', automatic printing of output is
suppressed, as if the \fB\-n\fR option were given on the command line.
.SH "BASIC REGULAR EXPRESSIONS"
.IX Header "BASIC REGULAR EXPRESSIONS"
A \fIBasic Regular Expression\fR (\s-1BRE\s0), as defined in \s-1POSIX\s0 1003.2, consists
of \fIatoms\fR, for matching parts of a string, and \fIbounds\fR, specifying
repetitions of a preceding atom.
.SS "Atoms"
.IX Subsection "Atoms"
The possible atoms of a \s-1BRE\s0 are: \fB.\fR, matching any single character;
\&\fB^\fR and \fB$\fR, matching the null string at the beginning or end
of a string, respectively; a \fIbracket expressions\fR, enclosed
in \fB[\fR and \fB]\fR (see below); and any single character with no
other significance (matching that character). A \fB\e\fR before one
of: \fB.\fR, \fB^\fR, \fB$\fR, \fB[\fR, \fB*\fR, \fB\e\fR, matching the character
after the backslash. A sequence of atoms enclosed in \fB\e(\fR and \fB\e)\fR
becomes an atom and establishes the target for a \fIbackreference\fR,
consisting of the substring that actually matches the enclosed atoms.
Finally, \fB\e\fR followed by one of the digits \fB0\fR through \fB9\fR is a
backreference.
.PP
A \fB^\fR that is not first, or a \fB$\fR that is not last does not have
a special significance and need not be preceded by a backslash to
become literal. The same is true for a \fB]\fR, that does not terminate
a bracket expression.
.PP
An unescaped backslash cannot be last in a \s-1BRE\s0.
.SS "Bounds"
.IX Subsection "Bounds"
The \s-1BRE\s0 bounds are: \fB*\fR, specifying 0 or more matches of the preceding
atom; \fB\e{\fR\fIcount\fR\fB\e}\fR, specifying that many repetitions;
\&\fB\e{\fR\fIminimum\fR\fB,\e}\fR, giving a lower limit; and
\&\fB\e{\fR\fIminimum\fR\fB,\fR\fImaximum\fR\fB\e}\fR finally defines a lower and upper
bound.
.PP
A bound appearing as the first item in a \s-1BRE\s0 is taken literally.
.SS "Bracket Expressions"
.IX Subsection "Bracket Expressions"
A \fIbracket expression\fR is a list of characters, character ranges
and character classes enclosed in \fB[\fR and \fB]\fR and matches any
single character from the represented set of characters.
.PP
A character range is written as two characters separated by \fB\-\fR and
represents all characters (according to the character collating sequence)
that are not less than the first and not greater than the second.
(Ranges are very collating-sequence-dependent, and portable programs
should avoid relying on them.)
.PP
A character class is one of the class names
.PP
.Vb 4
\&   alnum     digit     punct
\&   alpha     graph     space
\&   blank     lower     upper
\&   cntrl     print     xdigit
.Ve
.PP
enclosed in \fB[:\fR and \fB:]\fR and represents the set of characters
as defined in \fIctype\fR\|(3).
.PP
If the first character after \fB[\fR is \fB^\fR, the sense of matching is
inverted.
.PP
To include a literal '\f(CW\*(C`^\*(C'\fR', place it anywhere else but first. To
include a literal '\f(CW\*(C`]\*(C'\fR' place it first or immediately after an
initial \fB^\fR. To include a literal '\f(CW\*(C`\-\*(C'\fR' make it the first (or
second after \fB^\fR) or last character, or the second endpoint of
a range.
.PP
The special bracket expression constructs \f(CW\*(C`[[:<:]]\*(C'\fR and \f(CW\*(C`[[:>:]]\*(C'\fR 
match the null string at the beginning and end of a word respectively.
(Note that neither is identical to Perl's '\eb' atom.)
.SS "Additional Atoms"
.IX Subsection "Additional Atoms"
Since some sed implementations provide additional regular expression
atoms (not defined in \s-1POSIX\s0 1003.2), \fBpsed\fR is capable of translating
the following backslash escapes:
.ie n .IP "\fB\e<\fR This is the same as ""[[:>:]]""." 4
.el .IP "\fB\e<\fR This is the same as \f(CW[[:>:]]\fR." 4
.IX Item "< This is the same as [[:>:]]."
.PD 0
.ie n .IP "\fB\e>\fR This is the same as ""[[:<:]]""." 4
.el .IP "\fB\e>\fR This is the same as \f(CW[[:<:]]\fR." 4
.IX Item "> This is the same as [[:<:]]."
.ie n .IP "\fB\ew\fR This is an abbreviation for ""[[:alnum:]_]""." 4
.el .IP "\fB\ew\fR This is an abbreviation for \f(CW[[:alnum:]_]\fR." 4
.IX Item "w This is an abbreviation for [[:alnum:]_]."
.ie n .IP "\fB\eW\fR This is an abbreviation for ""[^[:alnum:]_]""." 4
.el .IP "\fB\eW\fR This is an abbreviation for \f(CW[^[:alnum:]_]\fR." 4
.IX Item "W This is an abbreviation for [^[:alnum:]_]."
.IP "\fB\ey\fR Match the empty string at a word boundary." 4
.IX Item "y Match the empty string at a word boundary."
.IP "\fB\eB\fR Match the empty string between any two either word or non-word characters." 4
.IX Item "B Match the empty string between any two either word or non-word characters."
.PD
.PP
To enable this feature, the environment variable \s-1PSEDEXTBRE\s0 must be set
to a string containing the requested characters, e.g.:
\&\f(CW\*(C`PSEDEXTBRE=\*(Aq<>wW\*(Aq\*(C'\fR.
.SH "ENVIRONMENT"
.IX Header "ENVIRONMENT"
The environment variable \f(CW\*(C`PSEDEXTBRE\*(C'\fR may be set to extend BREs.
See \*(L"Additional Atoms\*(R".
.SH "DIAGNOSTICS"
.IX Header "DIAGNOSTICS"
.IP "ambiguous translation for character '%s' in 'y' command" 4
.IX Item "ambiguous translation for character '%s' in 'y' command"
The indicated character appears twice, with different translations.
.IP "'[' cannot be last in pattern" 4
.IX Item "'[' cannot be last in pattern"
A '[' in a \s-1BRE\s0 indicates the beginning of a \fIbracket expression\fR.
.IP "'\e' cannot be last in pattern" 4
.IX Item "'' cannot be last in pattern"
A '\e' in a \s-1BRE\s0 is used to make the subsequent character literal.
.IP "'\e' cannot be last in substitution" 4
.IX Item "'' cannot be last in substitution"
A '\e' in a substitution string is used to make the subsequent character literal.
.IP "conflicting flags '%s'" 4
.IX Item "conflicting flags '%s'"
In an \fBs\fR command, either the 'g' flag and an n\-th occurrence flag, or
multiple n\-th occurrence flags are specified. Note that only the digits
^'1' through '9' are permitted.
.ie n .IP "duplicate label %s (first defined at %s)" 4
.el .IP "duplicate label \f(CW%s\fR (first defined at \f(CW%s\fR)" 4
.IX Item "duplicate label %s (first defined at %s)"
.PD 0
.IP "excess address(es)" 4
.IX Item "excess address(es)"
.PD
The command has more than the permitted number of addresses.
.IP "extra characters after command (%s)" 4
.IX Item "extra characters after command (%s)"
.PD 0
.IP "illegal option '%s'" 4
.IX Item "illegal option '%s'"
.IP "improper delimiter in s command" 4
.IX Item "improper delimiter in s command"
.PD
The \s-1BRE\s0 and substitution may not be delimited with '\e' or newline.
.IP "invalid address after ','" 4
.IX Item "invalid address after ','"
.PD 0
.IP "invalid backreference (%s)" 4
.IX Item "invalid backreference (%s)"
.PD
The specified backreference number exceeds the number of backreferences
in the \s-1BRE\s0.
.IP "invalid repeat clause '\e{%s\e}'" 4
.IX Item "invalid repeat clause '{%s}'"
The repeat clause does not contain a valid integer value, or pair of
values.
.IP "malformed regex, 1st address" 4
.IX Item "malformed regex, 1st address"
.PD 0
.IP "malformed regex, 2nd address" 4
.IX Item "malformed regex, 2nd address"
.IP "malformed regular expression" 4
.IX Item "malformed regular expression"
.IP "malformed substitution expression" 4
.IX Item "malformed substitution expression"
.IP "malformed 'y' command argument" 4
.IX Item "malformed 'y' command argument"
.PD
The first or second string of a \fBy\fR command  is syntactically incorrect.
.IP "maximum less than minimum in '\e{%s\e}'" 4
.IX Item "maximum less than minimum in '{%s}'"
.PD 0
.IP "no script command given" 4
.IX Item "no script command given"
.PD
There must be at least one \fB\-e\fR or one \fB\-f\fR option specifying a
script or script file.
.IP "'\e' not valid as delimiter in 'y' command" 4
.IX Item "'' not valid as delimiter in 'y' command"
.PD 0
.IP "option \-e requires an argument" 4
.IX Item "option -e requires an argument"
.IP "option \-f requires an argument" 4
.IX Item "option -f requires an argument"
.IP "'s' command requires argument" 4
.IX Item "'s' command requires argument"
.IP "start of unterminated '{'" 4
.IX Item "start of unterminated '{'"
.IP "string lengths in 'y' command differ" 4
.IX Item "string lengths in 'y' command differ"
.PD
The translation table strings in a \fBy\fR command must have equal lengths.
.IP "undefined label '%s'" 4
.IX Item "undefined label '%s'"
.PD 0
.IP "unexpected '}'" 4
.IX Item "unexpected '}'"
.PD
A \fB}\fR command without a preceding \fB{\fR command was encountered.
.IP "unexpected end of script" 4
.IX Item "unexpected end of script"
The end of the script was reached although a text line after a
\&\fBa\fR, \fBc\fR or \fBi\fR command indicated another line.
.IP "unknown command '%s'" 4
.IX Item "unknown command '%s'"
.PD 0
.IP "unterminated '['" 4
.IX Item "unterminated '['"
.PD
A \s-1BRE\s0 contains an unterminated bracket expression.
.IP "unterminated '\e('" 4
.IX Item "unterminated '('"
A \s-1BRE\s0 contains an unterminated backreference.
.IP "'\e{' without closing '\e}'" 4
.IX Item "'{' without closing '}'"
A \s-1BRE\s0 contains an unterminated bounds specification.
.IP "'\e)' without preceding '\e('" 4
.IX Item "')' without preceding '('"
.PD 0
.IP "'y' command requires argument" 4
.IX Item "'y' command requires argument"
.PD
.SH "EXAMPLE"
.IX Header "EXAMPLE"
The basic material for the preceding section was generated by running
the sed script
.PP
.Vb 10
\&   #no autoprint
\&   s/^.*Warn( *"\e([^"]*\e)".*$/\e1/
\&   t process
\&   b
\&   :process
\&   s/$!/%s/g
\&   s/$[_[:alnum:]]\e{1,\e}/%s/g
\&   s/\e\e\e\e/\e\e/g
\&   s/^/=item /
\&   p
.Ve
.PP
on the program's own text, and piping the output into \f(CW\*(C`sort \-u\*(C'\fR.
.SH "SED SCRIPT TRANSLATION"
.IX Header "SED SCRIPT TRANSLATION"
If this program is invoked with the name \fIs2p\fR it will act as a
sed-to-Perl translator. After option processing (all other
arguments are ignored), a Perl program is printed on standard
output, which will process the input stream (as read from all
arguments) in the way defined by the sed script and the option setting
used for the translation.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
\&\fIperl\fR\|(1), \fIre_format\fR\|(7)
.SH "BUGS"
.IX Header "BUGS"
The \fBl\fR command will show escape characters (\s-1ESC\s0) as '\f(CW\*(C`\ee\*(C'\fR', but
a vertical tab (\s-1VT\s0) in octal.
.PP
Trailing spaces are truncated from labels in \fB:\fR, \fBt\fR and \fBb\fR commands.
.PP
The meaning of an empty regular expression ('\f(CW\*(C`//\*(C'\fR'), as defined by \fBsed\fR,
is \*(L"the last pattern used, at run time\*(R". This deviates from the Perl
interpretation, which will re-use the \*(L"last last successfully executed
regular expression\*(R". Since keeping track of pattern usage would create
terribly cluttered code, and differences would only appear in obscure
context (where other \fBsed\fR implementations appear to deviate, too),
the Perl semantics was adopted. Note that common usage of this feature,
such as in \f(CW\*(C`/abc/s//xyz/\*(C'\fR, will work as expected.
.PP
Collating elements (of bracket expressions in BREs) are not implemented.
.SH "STANDARDS"
.IX Header "STANDARDS"
This \fBsed\fR implementation conforms to the \s-1IEEE\s0 Std1003.2\-1992 (\*(L"\s-1POSIX\s0.2\*(R")
definition of \fBsed\fR, and is compatible with the \fIOpenBSD\fR
implementation, except where otherwise noted (see \*(L"\s-1BUGS\s0\*(R").
.SH "AUTHOR"
.IX Header "AUTHOR"
This Perl implementation of \fIsed\fR was written by Wolfgang Laun,
\&\fIWolfgang.Laun@alcatel.at\fR.
.SH "COPYRIGHT and LICENSE"
.IX Header "COPYRIGHT and LICENSE"
This program is free and open software. You may use, modify,
distribute, and sell this program (and any modified variants) in any
way you wish, provided you do not restrict others from doing the same.
