Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v9 / man / man1 / s2p.1
CommitLineData
920dae64
AT
1.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32
2.\"
3.\" Standard preamble:
4.\" ========================================================================
5.de Sh \" Subsection heading
6.br
7.if t .Sp
8.ne 5
9.PP
10\fB\\$1\fR
11.PP
12..
13.de Sp \" Vertical space (when we can't use .PP)
14.if t .sp .5v
15.if n .sp
16..
17.de Vb \" Begin verbatim text
18.ft CW
19.nf
20.ne \\$1
21..
22.de Ve \" End verbatim text
23.ft R
24.fi
25..
26.\" Set up some character translations and predefined strings. \*(-- will
27.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28.\" double quote, and \*(R" will give a right double quote. | will give a
29.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
30.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
31.\" expand to `' in nroff, nothing in troff, for use with C<>.
32.tr \(*W-|\(bv\*(Tr
33.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34.ie n \{\
35. ds -- \(*W-
36. ds PI pi
37. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
39. ds L" ""
40. ds R" ""
41. ds C` ""
42. ds C' ""
43'br\}
44.el\{\
45. ds -- \|\(em\|
46. ds PI \(*p
47. ds L" ``
48. ds R" ''
49'br\}
50.\"
51.\" If the F register is turned on, we'll generate index entries on stderr for
52.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53.\" entries marked with X<> in POD. Of course, you'll have to process the
54.\" output yourself in some meaningful fashion.
55.if \nF \{\
56. de IX
57. tm Index:\\$1\t\\n%\t"\\$2"
58..
59. nr % 0
60. rr F
61.\}
62.\"
63.\" For nroff, turn off justification. Always turn off hyphenation; it makes
64.\" way too many mistakes in technical documents.
65.hy 0
66.if n .na
67.\"
68.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69.\" Fear. Run. Save yourself. No user-serviceable parts.
70. \" fudge factors for nroff and troff
71.if n \{\
72. ds #H 0
73. ds #V .8m
74. ds #F .3m
75. ds #[ \f1
76. ds #] \fP
77.\}
78.if t \{\
79. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80. ds #V .6m
81. ds #F 0
82. ds #[ \&
83. ds #] \&
84.\}
85. \" simple accents for nroff and troff
86.if n \{\
87. ds ' \&
88. ds ` \&
89. ds ^ \&
90. ds , \&
91. ds ~ ~
92. ds /
93.\}
94.if t \{\
95. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101.\}
102. \" troff and (daisy-wheel) nroff accents
103.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110.ds ae a\h'-(\w'a'u*4/10)'e
111.ds Ae A\h'-(\w'A'u*4/10)'E
112. \" corrections for vroff
113.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115. \" for low resolution devices (crt and lpr)
116.if \n(.H>23 .if \n(.V>19 \
117\{\
118. ds : e
119. ds 8 ss
120. ds o a
121. ds d- d\h'-1'\(ga
122. ds D- D\h'-1'\(hy
123. ds th \o'bp'
124. ds Th \o'LP'
125. ds ae ae
126. ds Ae AE
127.\}
128.rm #[ #] #H #V #F C
129.\" ========================================================================
130.\"
131.IX Title "S2P 1"
132.TH S2P 1 "2007-06-19" "perl v5.8.8" "Perl Programmers Reference Guide"
133.SH "NAME"
134psed \- a stream editor
135.SH "SYNOPSIS"
136.IX Header "SYNOPSIS"
137.Vb 2
138\& psed [-an] script [file ...]
139\& psed [-an] [-e script] [-f script-file] [file ...]
140.Ve
141.PP
142.Vb 1
143\& s2p [-an] [-e script] [-f script-file]
144.Ve
145.SH "DESCRIPTION"
146.IX Header "DESCRIPTION"
147A stream editor reads the input stream consisting of the specified files
148(or standard input, if none are given), processes is line by line by
149applying a script consisting of edit commands, and writes resulting lines
150to standard output. The filename `\f(CW\*(C`\-\*(C'\fR' may be used to read standard input.
151.PP
152The edit script is composed from arguments of \fB\-e\fR options and
153script\-files, in the given order. A single script argument may be specified
154as the first parameter.
155.PP
156If this program is invoked with the name \fIs2p\fR, it will act as a
157sed-to-Perl translator. See \*(L"sed Script Translation\*(R".
158.PP
159\&\fBsed\fR returns an exit code of 0 on success or >0 if an error occurred.
160.SH "OPTIONS"
161.IX Header "OPTIONS"
162.IP "\fB\-a\fR" 4
163.IX Item "-a"
164A file specified as argument to the \fBw\fR edit command is by default
165opened before input processing starts. Using \fB\-a\fR, opening of such
166files is delayed until the first line is actually written to the file.
167.IP "\fB\-e\fR \fIscript\fR" 4
168.IX Item "-e script"
169The editing commands defined by \fIscript\fR are appended to the script.
170Multiple commands must be separated by newlines.
171.IP "\fB\-f\fR \fIscript-file\fR" 4
172.IX Item "-f script-file"
173Editing commands from the specified \fIscript-file\fR are read and appended
174to the script.
175.IP "\fB\-n\fR" 4
176.IX Item "-n"
177By default, a line is written to standard output after the editing script
178has been applied to it. The \fB\-n\fR option suppresses automatic printing.
179.SH "COMMANDS"
180.IX Header "COMMANDS"
181\&\fBsed\fR command syntax is defined as
182.PP
183\&\& \& \& \&[\fIaddress\fR[\fB,\fR\fIaddress\fR]][\fB!\fR]\fIfunction\fR[\fIargument\fR]
184.PP
185with whitespace being permitted before or after addresses, and between
186the function character and the argument. The \fIaddress\fRes and the
187address inverter (\f(CW\*(C`!\*(C'\fR) are used to restrict the application of a
188command to the selected line(s) of input.
189.PP
190Each command must be on a line of its own, except where noted in
191the synopses below.
192.PP
193The edit cycle performed on each input line consist of reading the line
194(without its trailing newline character) into the \fIpattern space\fR,
195applying the applicable commands of the edit script, writing the final
196contents of the pattern space and a newline to the standard output.
197A \fIhold space\fR is provided for saving the contents of the
198pattern space for later use.
199.Sh "Addresses"
200.IX Subsection "Addresses"
201A sed address is either a line number or a pattern, which may be combined
202arbitrarily to construct ranges. Lines are numbered across all input files.
203.PP
204Any address may be followed by an exclamation mark (`\f(CW\*(C`!\*(C'\fR'), selecting
205all lines not matching that address.
206.IP "\fInumber\fR" 4
207.IX Item "number"
208The line with the given number is selected.
209.IP "\fB$\fR" 4
210.IX Item "$"
211A dollar sign (\f(CW\*(C`$\*(C'\fR) is the line number of the last line of the input stream.
212.IP "\fB/\fR\fIregular expression\fR\fB/\fR" 4
213.IX Item "/regular expression/"
214A pattern address is a basic regular expression (see
215\&\*(L"Basic Regular Expressions\*(R"), between the delimiting character \f(CW\*(C`/\*(C'\fR.
216Any other character except \f(CW\*(C`\e\*(C'\fR or newline may be used to delimit a
217pattern address when the initial delimiter is prefixed with a
218backslash (`\f(CW\*(C`\e\*(C'\fR').
219.PP
220If no address is given, the command selects every line.
221.PP
222If one address is given, it selects the line (or lines) matching the
223address.
224.PP
225Two addresses select a range that begins whenever the first address
226matches, and ends (including that line) when the second address matches.
227If the first (second) address is a matching pattern, the second
228address is not applied to the very same line to determine the end of
229the range. Likewise, if the second address is a matching pattern, the
230first address is not applied to the very same line to determine the
231begin of another range. If both addresses are line numbers,
232and the second line number is less than the first line number, then
233only the first line is selected.
234.Sh "Functions"
235.IX Subsection "Functions"
236The maximum permitted number of addresses is indicated with each
237function synopsis below.
238.PP
239The argument \fItext\fR consists of one or more lines following the command.
240Embedded newlines in \fItext\fR must be preceded with a backslash. Other
241backslashes in \fItext\fR are deleted and the following character is taken
242literally.
243.IP "[1addr]\fBa\e\fR \fItext\fR" 4
244.IX Item "[1addr]a text"
245Write \fItext\fR (which must start on the line following the command)
246to standard output immediately before reading the next line
247of input, either by executing the \fBN\fR function or by beginning a new cycle.
248.IP "[2addr]\fBb\fR [\fIlabel\fR]" 4
249.IX Item "[2addr]b [label]"
250Branch to the \fB:\fR function with the specified \fIlabel\fR. If no label
251is given, branch to the end of the script.
252.IP "[2addr]\fBc\e\fR \fItext\fR" 4
253.IX Item "[2addr]c text"
254The line, or range of lines, selected by the address is deleted.
255The \fItext\fR (which must start on the line following the command)
256is written to standard output. With an address range, this occurs at
257the end of the range.
258.IP "[2addr]\fBd\fR" 4
259.IX Item "[2addr]d"
260Deletes the pattern space and starts the next cycle.
261.IP "[2addr]\fBD\fR" 4
262.IX Item "[2addr]D"
263Deletes the pattern space through the first embedded newline or to the end.
264If the pattern space becomes empty, a new cycle is started, otherwise
265execution of the script is restarted.
266.IP "[2addr]\fBg\fR" 4
267.IX Item "[2addr]g"
268Replace the contents of the pattern space with the hold space.
269.IP "[2addr]\fBG\fR" 4
270.IX Item "[2addr]G"
271Append a newline and the contents of the hold space to the pattern space.
272.IP "[2addr]\fBh\fR" 4
273.IX Item "[2addr]h"
274Replace the contents of the hold space with the pattern space.
275.IP "[2addr]\fBH\fR" 4
276.IX Item "[2addr]H"
277Append a newline and the contents of the pattern space to the hold space.
278.IP "[1addr]\fBi\e\fR \fItext\fR" 4
279.IX Item "[1addr]i text"
280Write the \fItext\fR (which must start on the line following the command)
281to standard output.
282.IP "[2addr]\fBl\fR" 4
283.IX Item "[2addr]l"
284Print the contents of the pattern space: non-printable characters are
285shown in C\-style escaped form; long lines are split and have a trailing
286`\f(CW\*(C`\e\*(C'\fR' at the point of the split; the true end of a line is marked with
287a `\f(CW\*(C`$\*(C'\fR'. Escapes are: `\ea', `\et', `\en', `\ef', `\er', `\ee' for
288\&\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
289octal number for all other non-printable characters.
290.IP "[2addr]\fBn\fR" 4
291.IX Item "[2addr]n"
292If automatic printing is enabled, write the pattern space to the standard
293output. Replace the pattern space with the next line of input. If
294there is no more input, processing is terminated.
295.IP "[2addr]\fBN\fR" 4
296.IX Item "[2addr]N"
297Append a newline and the next line of input to the pattern space. If
298there is no more input, processing is terminated.
299.IP "[2addr]\fBp\fR" 4
300.IX Item "[2addr]p"
301Print the pattern space to the standard output. (Use the \fB\-n\fR option
302to suppress automatic printing at the end of a cycle if you want to
303avoid double printing of lines.)
304.IP "[2addr]\fBP\fR" 4
305.IX Item "[2addr]P"
306Prints the pattern space through the first embedded newline or to the end.
307.IP "[1addr]\fBq\fR" 4
308.IX Item "[1addr]q"
309Branch to the end of the script and quit without starting a new cycle.
310.IP "[1addr]\fBr\fR \fIfile\fR" 4
311.IX Item "[1addr]r file"
312Copy the contents of the \fIfile\fR to standard output immediately before
313the next attempt to read a line of input. Any error encountered while
314reading \fIfile\fR is silently ignored.
315.IP "[2addr]\fBs/\fR\fIregular expression\fR\fB/\fR\fIreplacement\fR\fB/\fR\fIflags\fR" 4
316.IX Item "[2addr]s/regular expression/replacement/flags"
317Substitute the \fIreplacement\fR string for the first substring in
318the pattern space that matches the \fIregular expression\fR.
319Any character other than backslash or newline can be used instead of a
320slash to delimit the regular expression and the replacement.
321To use the delimiter as a literal character within the regular expression
322and the replacement, precede the character by a backslash (`\f(CW\*(C`\e\*(C'\fR').
323.Sp
324Literal newlines may be embedded in the replacement string by
325preceding a newline with a backslash.
326.Sp
327Within the replacement, an ampersand (`\f(CW\*(C`&\*(C'\fR') is replaced by the string
328matching the regular expression. The strings `\f(CW\*(C`\e1\*(C'\fR' through `\f(CW\*(C`\e9\*(C'\fR' are
329replaced by the corresponding subpattern (see \*(L"Basic Regular Expressions\*(R").
330To get a literal `\f(CW\*(C`&\*(C'\fR' or `\f(CW\*(C`\e\*(C'\fR' in the replacement text, precede it
331by a backslash.
332.Sp
333The following \fIflags\fR modify the behaviour of the \fBs\fR command:
334.RS 4
335.IP "\fBg\fR" 8
336.IX Item "g"
337The replacement is performed for all matching, non-overlapping substrings
338of the pattern space.
339.IP "\fB1\fR..\fB9\fR" 8
340.IX Item "1..9"
341Replace only the n\-th matching substring of the pattern space.
342.IP "\fBp\fR" 8
343.IX Item "p"
344If the substitution was made, print the new value of the pattern space.
345.IP "\fBw\fR \fIfile\fR" 8
346.IX Item "w file"
347If the substitution was made, write the new value of the pattern space
348to the specified file.
349.RE
350.RS 4
351.RE
352.IP "[2addr]\fBt\fR [\fIlabel\fR]" 4
353.IX Item "[2addr]t [label]"
354Branch to the \fB:\fR function with the specified \fIlabel\fR if any \fBs\fR
355substitutions have been made since the most recent reading of an input line
356or execution of a \fBt\fR function. If no label is given, branch to the end of
357the script.
358.IP "[2addr]\fBw\fR \fIfile\fR" 4
359.IX Item "[2addr]w file"
360The contents of the pattern space are written to the \fIfile\fR.
361.IP "[2addr]\fBx\fR" 4
362.IX Item "[2addr]x"
363Swap the contents of the pattern space and the hold space.
364.IP "[1addr]\fB=\fR" 4
365.IX Item "[1addr]="
366Prints the current line number on the standard output.
367.IP "[0addr]\fB:\fR [\fIlabel\fR]" 4
368.IX Item "[0addr]: [label]"
369The command specifies the position of the \fIlabel\fR. It has no other effect.
370.IP "[2addr]\fB{\fR [\fIcommand\fR]" 4
371.IX Item "[2addr]{ [command]"
372.PD 0
373.IP "[0addr]\fB}\fR" 4
374.IX Item "[0addr]}"
375.PD
376These two commands begin and end a command list. The first command may
377be given on the same line as the opening \fB{\fR command. The commands
378within the list are jointly selected by the address(es) given on the
379\&\fB{\fR command (but may still have individual addresses).
380.IP "[0addr]\fB#\fR [\fIcomment\fR]" 4
381.IX Item "[0addr]# [comment]"
382The entire line is ignored (treated as a comment). If, however, the first
383two characters in the script are `\f(CW\*(C`#n\*(C'\fR', automatic printing of output is
384suppressed, as if the \fB\-n\fR option were given on the command line.
385.SH "BASIC REGULAR EXPRESSIONS"
386.IX Header "BASIC REGULAR EXPRESSIONS"
387A \fIBasic Regular Expression\fR (\s-1BRE\s0), as defined in \s-1POSIX\s0 1003.2, consists
388of \fIatoms\fR, for matching parts of a string, and \fIbounds\fR, specifying
389repetitions of a preceding atom.
390.Sh "Atoms"
391.IX Subsection "Atoms"
392The possible atoms of a \s-1BRE\s0 are: \fB.\fR, matching any single character;
393\&\fB^\fR and \fB$\fR, matching the null string at the beginning or end
394of a string, respectively; a \fIbracket expressions\fR, enclosed
395in \fB[\fR and \fB]\fR (see below); and any single character with no
396other significance (matching that character). A \fB\e\fR before one
397of: \fB.\fR, \fB^\fR, \fB$\fR, \fB[\fR, \fB*\fR, \fB\e\fR, matching the character
398after the backslash. A sequence of atoms enclosed in \fB\e(\fR and \fB\e)\fR
399becomes an atom and establishes the target for a \fIbackreference\fR,
400consisting of the substring that actually matches the enclosed atoms.
401Finally, \fB\e\fR followed by one of the digits \fB0\fR through \fB9\fR is a
402backreference.
403.PP
404A \fB^\fR that is not first, or a \fB$\fR that is not last does not have
405a special significance and need not be preceded by a backslash to
406become literal. The same is true for a \fB]\fR, that does not terminate
407a bracket expression.
408.PP
409An unescaped backslash cannot be last in a \s-1BRE\s0.
410.Sh "Bounds"
411.IX Subsection "Bounds"
412The \s-1BRE\s0 bounds are: \fB*\fR, specifying 0 or more matches of the preceding
413atom; \fB\e{\fR\fIcount\fR\fB\e}\fR, specifying that many repetitions;
414\&\fB\e{\fR\fIminimum\fR\fB,\e}\fR, giving a lower limit; and
415\&\fB\e{\fR\fIminimum\fR\fB,\fR\fImaximum\fR\fB\e}\fR finally defines a lower and upper
416bound.
417.PP
418A bound appearing as the first item in a \s-1BRE\s0 is taken literally.
419.Sh "Bracket Expressions"
420.IX Subsection "Bracket Expressions"
421A \fIbracket expression\fR is a list of characters, character ranges
422and character classes enclosed in \fB[\fR and \fB]\fR and matches any
423single character from the represented set of characters.
424.PP
425A character range is written as two characters separated by \fB\-\fR and
426represents all characters (according to the character collating sequence)
427that are not less than the first and not greater than the second.
428(Ranges are very collating\-sequence\-dependent, and portable programs
429should avoid relying on them.)
430.PP
431A character class is one of the class names
432.PP
433.Vb 4
434\& alnum digit punct
435\& alpha graph space
436\& blank lower upper
437\& cntrl print xdigit
438.Ve
439.PP
440enclosed in \fB[:\fR and \fB:]\fR and represents the set of characters
441as defined in \fIctype\fR\|(3).
442.PP
443If the first character after \fB[\fR is \fB^\fR, the sense of matching is
444inverted.
445.PP
446To include a literal `\f(CW\*(C`^\*(C'\fR', place it anywhere else but first. To
447include a literal '\f(CW\*(C`]\*(C'\fR' place it first or immediately after an
448initial \fB^\fR. To include a literal `\f(CW\*(C`\-\*(C'\fR' make it the first (or
449second after \fB^\fR) or last character, or the second endpoint of
450a range.
451.PP
452The special bracket expression constructs \f(CW\*(C`[[:<:]]\*(C'\fR and \f(CW\*(C`[[:>:]]\*(C'\fR
453match the null string at the beginning and end of a word respectively.
454(Note that neither is identical to Perl's `\eb' atom.)
455.Sh "Additional Atoms"
456.IX Subsection "Additional Atoms"
457Since some sed implementations provide additional regular expression
458atoms (not defined in \s-1POSIX\s0 1003.2), \fBpsed\fR is capable of translating
459the following backslash escapes:
460.ie n .IP "\fB\e<\fR This is the same as ""[[:>:]]""." 4
461.el .IP "\fB\e<\fR This is the same as \f(CW[[:>:]]\fR." 4
462.IX Item "< This is the same as [[:>:]]."
463.PD 0
464.ie n .IP "\fB\e>\fR This is the same as ""[[:<:]]""." 4
465.el .IP "\fB\e>\fR This is the same as \f(CW[[:<:]]\fR." 4
466.IX Item "> This is the same as [[:<:]]."
467.ie n .IP "\fB\ew\fR This is an abbreviation for ""[[:alnum:]_]""." 4
468.el .IP "\fB\ew\fR This is an abbreviation for \f(CW[[:alnum:]_]\fR." 4
469.IX Item "w This is an abbreviation for [[:alnum:]_]."
470.ie n .IP "\fB\eW\fR This is an abbreviation for ""[^[:alnum:]_]""." 4
471.el .IP "\fB\eW\fR This is an abbreviation for \f(CW[^[:alnum:]_]\fR." 4
472.IX Item "W This is an abbreviation for [^[:alnum:]_]."
473.IP "\fB\ey\fR Match the empty string at a word boundary." 4
474.IX Item "y Match the empty string at a word boundary."
475.IP "\fB\eB\fR Match the empty string between any two either word or non-word characters." 4
476.IX Item "B Match the empty string between any two either word or non-word characters."
477.PD
478.PP
479To enable this feature, the environment variable \s-1PSEDEXTBRE\s0 must be set
480to a string containing the requested characters, e.g.:
481\&\f(CW\*(C`PSEDEXTBRE='<>wW'\*(C'\fR.
482.SH "ENVIRONMENT"
483.IX Header "ENVIRONMENT"
484The environment variable \f(CW\*(C`PSEDEXTBRE\*(C'\fR may be set to extend BREs.
485See \*(L"Additional Atoms\*(R".
486.SH "DIAGNOSTICS"
487.IX Header "DIAGNOSTICS"
488.IP "ambiguous translation for character `%s' in `y' command" 4
489.IX Item "ambiguous translation for character `%s' in `y' command"
490The indicated character appears twice, with different translations.
491.IP "`[' cannot be last in pattern" 4
492.IX Item "`[' cannot be last in pattern"
493A `[' in a \s-1BRE\s0 indicates the beginning of a \fIbracket expression\fR.
494.IP "`\e' cannot be last in pattern" 4
495.IX Item "`' cannot be last in pattern"
496A `\e' in a \s-1BRE\s0 is used to make the subsequent character literal.
497.IP "`\e' cannot be last in substitution" 4
498.IX Item "`' cannot be last in substitution"
499A `\e' in a subsitution string is used to make the subsequent character literal.
500.IP "conflicting flags `%s'" 4
501.IX Item "conflicting flags `%s'"
502In an \fBs\fR command, either the `g' flag and an n\-th occurrence flag, or
503multiple n\-th occurrence flags are specified. Note that only the digits
504`1' through `9' are permitted.
505.ie n .IP "duplicate label %s\fR (first defined at \f(CW%s)" 4
506.el .IP "duplicate label \f(CW%s\fR (first defined at \f(CW%s\fR)" 4
507.IX Item "duplicate label %s (first defined at %s)"
508.PD 0
509.IP "excess address(es)" 4
510.IX Item "excess address(es)"
511.PD
512The command has more than the permitted number of addresses.
513.IP "extra characters after command (%s)" 4
514.IX Item "extra characters after command (%s)"
515.PD 0
516.IP "illegal option `%s'" 4
517.IX Item "illegal option `%s'"
518.IP "improper delimiter in s command" 4
519.IX Item "improper delimiter in s command"
520.PD
521The \s-1BRE\s0 and substitution may not be delimited with `\e' or newline.
522.IP "invalid address after `,'" 4
523.IX Item "invalid address after `,'"
524.PD 0
525.IP "invalid backreference (%s)" 4
526.IX Item "invalid backreference (%s)"
527.PD
528The specified backreference number exceeds the number of backreferences
529in the \s-1BRE\s0.
530.IP "invalid repeat clause `\e{%s\e}'" 4
531.IX Item "invalid repeat clause `{%s}'"
532The repeat clause does not contain a valid integer value, or pair of
533values.
534.IP "malformed regex, 1st address" 4
535.IX Item "malformed regex, 1st address"
536.PD 0
537.IP "malformed regex, 2nd address" 4
538.IX Item "malformed regex, 2nd address"
539.IP "malformed regular expression" 4
540.IX Item "malformed regular expression"
541.IP "malformed substitution expression" 4
542.IX Item "malformed substitution expression"
543.IP "malformed `y' command argument" 4
544.IX Item "malformed `y' command argument"
545.PD
546The first or second string of a \fBy\fR command is syntactically incorrect.
547.IP "maximum less than minimum in `\e{%s\e}'" 4
548.IX Item "maximum less than minimum in `{%s}'"
549.PD 0
550.IP "no script command given" 4
551.IX Item "no script command given"
552.PD
553There must be at least one \fB\-e\fR or one \fB\-f\fR option specifying a
554script or script file.
555.IP "`\e' not valid as delimiter in `y' command" 4
556.IX Item "`' not valid as delimiter in `y' command"
557.PD 0
558.IP "option \-e requires an argument" 4
559.IX Item "option -e requires an argument"
560.IP "option \-f requires an argument" 4
561.IX Item "option -f requires an argument"
562.IP "`s' command requires argument" 4
563.IX Item "`s' command requires argument"
564.IP "start of unterminated `{'" 4
565.IX Item "start of unterminated `{'"
566.IP "string lengths in `y' command differ" 4
567.IX Item "string lengths in `y' command differ"
568.PD
569The translation table strings in a \fBy\fR commanf must have equal lengths.
570.IP "undefined label `%s'" 4
571.IX Item "undefined label `%s'"
572.PD 0
573.IP "unexpected `}'" 4
574.IX Item "unexpected `}'"
575.PD
576A \fB}\fR command without a preceding \fB{\fR command was encountered.
577.IP "unexpected end of script" 4
578.IX Item "unexpected end of script"
579The end of the script was reached although a text line after a
580\&\fBa\fR, \fBc\fR or \fBi\fR command indicated another line.
581.IP "unknown command `%s'" 4
582.IX Item "unknown command `%s'"
583.PD 0
584.IP "unterminated `['" 4
585.IX Item "unterminated `['"
586.PD
587A \s-1BRE\s0 contains an unterminated bracket expression.
588.IP "unterminated `\e('" 4
589.IX Item "unterminated `('"
590A \s-1BRE\s0 contains an unterminated backreference.
591.IP "`\e{' without closing `\e}'" 4
592.IX Item "`{' without closing `}'"
593A \s-1BRE\s0 contains an unterminated bounds specification.
594.IP "`\e)' without preceding `\e('" 4
595.IX Item "`)' without preceding `('"
596.PD 0
597.IP "`y' command requires argument" 4
598.IX Item "`y' command requires argument"
599.PD
600.SH "EXAMPLE"
601.IX Header "EXAMPLE"
602The basic material for the preceding section was generated by running
603the sed script
604.PP
605.Vb 10
606\& #no autoprint
607\& s/^.*Warn( *"\e([^"]*\e)".*$/\e1/
608\& t process
609\& b
610\& :process
611\& s/$!/%s/g
612\& s/$[_[:alnum:]]\e{1,\e}/%s/g
613\& s/\e\e\e\e/\e\e/g
614\& s/^/=item /
615\& p
616.Ve
617.PP
618on the program's own text, and piping the output into \f(CW\*(C`sort \-u\*(C'\fR.
619.SH "SED SCRIPT TRANSLATION"
620.IX Header "SED SCRIPT TRANSLATION"
621If this program is invoked with the name \fIs2p\fR it will act as a
622sed-to-Perl translator. After option processing (all other
623arguments are ignored), a Perl program is printed on standard
624output, which will process the input stream (as read from all
625arguments) in the way defined by the sed script and the option setting
626used for the translation.
627.SH "SEE ALSO"
628.IX Header "SEE ALSO"
629\&\fIperl\fR\|(1), \fIre_format\fR\|(7)
630.SH "BUGS"
631.IX Header "BUGS"
632The \fBl\fR command will show escape characters (\s-1ESC\s0) as `\f(CW\*(C`\ee\*(C'\fR', but
633a vertical tab (\s-1VT\s0) in octal.
634.PP
635Trailing spaces are truncated from labels in \fB:\fR, \fBt\fR and \fBb\fR commands.
636.PP
637The meaning of an empty regular expression (`\f(CW\*(C`//\*(C'\fR'), as defined by \fBsed\fR,
638is \*(L"the last pattern used, at run time\*(R". This deviates from the Perl
639interpretation, which will re-use the \*(L"last last successfully executed
640regular expression\*(R". Since keeping track of pattern usage would create
641terribly cluttered code, and differences would only appear in obscure
642context (where other \fBsed\fR implementations appear to deviate, too),
643the Perl semantics was adopted. Note that common usage of this feature,
644such as in \f(CW\*(C`/abc/s//xyz/\*(C'\fR, will work as expected.
645.PP
646Collating elements (of bracket expressions in BREs) are not implemented.
647.SH "STANDARDS"
648.IX Header "STANDARDS"
649This \fBsed\fR implementation conforms to the \s-1IEEE\s0 Std1003.2\-1992 (\*(L"\s-1POSIX\s0.2\*(R")
650definition of \fBsed\fR, and is compatible with the \fIOpenBSD\fR
651implementation, except where otherwise noted (see \*(L"\s-1BUGS\s0\*(R").
652.SH "AUTHOR"
653.IX Header "AUTHOR"
654This Perl implementation of \fIsed\fR was written by Wolfgang Laun,
655\&\fIWolfgang.Laun@alcatel.at\fR.
656.SH "COPYRIGHT and LICENSE"
657.IX Header "COPYRIGHT and LICENSE"
658This program is free and open software. You may use, modify,
659distribute, and sell this program (and any modified variants) in any
660way you wish, provided you do not restrict others from doing the same.