VirtualBox

source: kBuild/vendor/sed/current/doc/sed.1

Last change on this file was 599, checked in by bird, 18 years ago

GNU sed 4.1.5.

File size: 8.4 KB
Line 
1.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.28.
2.TH SED "1" "February 2006" "sed version 4.1.4" "User Commands"
3.SH NAME
4sed \- stream editor for filtering and transforming text
5.SH SYNOPSIS
6.B sed
7[\fIOPTION\fR]... \fI{script-only-if-no-other-script} \fR[\fIinput-file\fR]...
8.SH DESCRIPTION
9.ds sd \fIsed\fP
10.ds Sd \fISed\fP
11\*(Sd is a stream editor.
12A stream editor is used to perform basic text
13transformations on an input stream
14(a file or input from a pipeline).
15While in some ways similar to an editor which
16permits scripted edits (such as \fIed\fP),
17\*(sd works by making only one pass over the
18input(s), and is consequently more efficient.
19But it is \*(sd's ability to filter text in a pipeline
20which particularly distinguishes it from other types of
21editors.
22.HP
23\fB\-n\fR, \fB\-\-quiet\fR, \fB\-\-silent\fR
24.IP
25suppress automatic printing of pattern space
26.HP
27\fB\-e\fR script, \fB\-\-expression\fR=\fIscript\fR
28.IP
29add the script to the commands to be executed
30.HP
31\fB\-f\fR script-file, \fB\-\-file\fR=\fIscript\-file\fR
32.IP
33add the contents of script-file to the commands to be executed
34.HP
35\fB\-i[SUFFIX]\fR, \fB\-\-in\-place\fR[=\fISUFFIX\fR]
36.IP
37edit files in place (makes backup if extension supplied)
38.HP
39\fB\-l\fR N, \fB\-\-line\-length\fR=\fIN\fR
40.IP
41specify the desired line-wrap length for the `l' command
42.HP
43\fB\-\-posix\fR
44.IP
45disable all GNU extensions.
46.HP
47\fB\-r\fR, \fB\-\-regexp\-extended\fR
48.IP
49use extended regular expressions in the script.
50.HP
51\fB\-s\fR, \fB\-\-separate\fR
52.IP
53consider files as separate rather than as a single continuous
54long stream.
55.HP
56\fB\-u\fR, \fB\-\-unbuffered\fR
57.IP
58load minimal amounts of data from the input files and flush
59the output buffers more often
60.TP
61\fB\-\-help\fR
62display this help and exit
63.TP
64\fB\-\-version\fR
65output version information and exit
66.PP
67If no \fB\-e\fR, \fB\-\-expression\fR, \fB\-f\fR, or \fB\-\-file\fR option is given, then the first
68non-option argument is taken as the sed script to interpret. All
69remaining arguments are names of input files; if no input files are
70specified, then the standard input is read.
71.PP
72E-mail bug reports to: bonzini@gnu.org .
73Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.
74.SH "COMMAND SYNOPSIS"
75This is just a brief synopsis of \*(sd commands to serve as
76a reminder to those who already know \*(sd;
77other documentation (such as the texinfo document)
78must be consulted for fuller descriptions.
79.SS
80Zero-address ``commands''
81.TP
82.RI :\ label
83Label for
84.B b
85and
86.B t
87commands.
88.TP
89.RI # comment
90The comment extends until the next newline (or the end of a
91.B -e
92script fragment).
93.TP
94}
95The closing bracket of a { } block.
96.SS
97Zero- or One- address commands
98.TP
99=
100Print the current line number.
101.TP
102a \e
103.TP
104.I text
105Append
106.IR text ,
107which has each embedded newline preceded by a backslash.
108.TP
109i \e
110.TP
111.I text
112Insert
113.IR text ,
114which has each embedded newline preceded by a backslash.
115.TP
116q
117Immediately quit the \*(sd script without processing
118any more input,
119except that if auto-print is not disabled
120the current pattern space will be printed.
121.TP
122Q
123Immediately quit the \*(sd script without processing
124any more input.
125.TP
126.RI r\ filename
127Append text read from
128.IR filename .
129.TP
130.RI R\ filename
131Append a line read from
132.IR filename .
133.SS
134Commands which accept address ranges
135.TP
136{
137Begin a block of commands (end with a }).
138.TP
139.RI b\ label
140Branch to
141.IR label ;
142if
143.I label
144is omitted, branch to end of script.
145.TP
146.RI t\ label
147If a s/// has done a successful substitution since the
148last input line was read and since the last t or T
149command, then branch to
150.IR label ;
151if
152.I label
153is omitted, branch to end of script.
154.TP
155.RI T\ label
156If no s/// has done a successful substitution since the
157last input line was read and since the last t or T
158command, then branch to
159.IR label ;
160if
161.I label
162is omitted, branch to end of script.
163.TP
164c \e
165.TP
166.I text
167Replace the selected lines with
168.IR text ,
169which has each embedded newline preceded by a backslash.
170.TP
171d
172Delete pattern space.
173Start next cycle.
174.TP
175D
176Delete up to the first embedded newline in the pattern space.
177Start next cycle, but skip reading from the input
178if there is still data in the pattern space.
179.TP
180h H
181Copy/append pattern space to hold space.
182.TP
183g G
184Copy/append hold space to pattern space.
185.TP
186x
187Exchange the contents of the hold and pattern spaces.
188.TP
189l
190List out the current line in a ``visually unambiguous'' form.
191.TP
192n N
193Read/append the next line of input into the pattern space.
194.TP
195p
196Print the current pattern space.
197.TP
198P
199Print up to the first embedded newline of the current pattern space.
200.TP
201.RI s/ regexp / replacement /
202Attempt to match
203.I regexp
204against the pattern space.
205If successful, replace that portion matched
206with
207.IR replacement .
208The
209.I replacement
210may contain the special character
211.B &
212to refer to that portion of the pattern space which matched,
213and the special escapes \e1 through \e9 to refer to the
214corresponding matching sub-expressions in the
215.IR regexp .
216.TP
217.RI w\ filename
218Write the current pattern space to
219.IR filename .
220.TP
221.RI W\ filename
222Write the first line of the current pattern space to
223.IR filename .
224.TP
225.RI y/ source / dest /
226Transliterate the characters in the pattern space which appear in
227.I source
228to the corresponding character in
229.IR dest .
230.SH
231Addresses
232\*(Sd commands can be given with no addresses, in which
233case the command will be executed for all input lines;
234with one address, in which case the command will only be executed
235for input lines which match that address; or with two
236addresses, in which case the command will be executed
237for all input lines which match the inclusive range of
238lines starting from the first address and continuing to
239the second address.
240Three things to note about address ranges:
241the syntax is
242.IR addr1 , addr2
243(i.e., the addresses are separated by a comma);
244the line which
245.I addr1
246matched will always be accepted,
247even if
248.I addr2
249selects an earlier line;
250and if
251.I addr2
252is a
253.IR regexp ,
254it will not be tested against the line that
255.I addr1
256matched.
257.PP
258After the address (or address-range),
259and before the command, a
260.B !
261may be inserted,
262which specifies that the command shall only be
263executed if the address (or address-range) does
264.B not
265match.
266.PP
267The following address types are supported:
268.TP
269.I number
270Match only the specified line
271.IR number .
272.TP
273.IR first ~ step
274Match every
275.IR step 'th
276line starting with line
277.IR first .
278For example, ``sed -n 1~2p'' will print all the odd-numbered lines in
279the input stream, and the address 2~5 will match every fifth line,
280starting with the second. (This is an extension.)
281.TP
282$
283Match the last line.
284.TP
285.RI / regexp /
286Match lines matching the regular expression
287.IR regexp .
288.TP
289.BI \fR\e\fPc regexp c
290Match lines matching the regular expression
291.IR regexp .
292The
293.B c
294may be any character.
295.PP
296GNU \*(sd also supports some special 2-address forms:
297.TP
298.RI 0, addr2
299Start out in "matched first address" state, until
300.I addr2
301is found.
302This is similar to
303.RI 1, addr2 ,
304except that if
305.I addr2
306matches the very first line of input the
307.RI 0, addr2
308form will be at the end of its range, whereas the
309.RI 1, addr2
310form will still be at the beginning of its range.
311.TP
312.IR addr1 ,+ N
313Will match
314.I addr1
315and the
316.I N
317lines following
318.IR addr1 .
319.TP
320.IR addr1 ,~ N
321Will match
322.I addr1
323and the lines following
324.I addr1
325until the next line whose input line number is a multiple of
326.IR N .
327.SH "REGULAR EXPRESSIONS"
328POSIX.2 BREs
329.I should
330be supported, but they aren't completely because of performance
331problems.
332The
333.B \en
334sequence in a regular expression matches the newline character,
335and similarly for
336.BR \ea ,
337.BR \et ,
338and other sequences.
339.SH BUGS
340.PP
341E-mail bug reports to
342.BR bonzini@gnu.org .
343Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.
344Also, please include the output of ``sed --version'' in the body
345of your report if at all possible.
346.SH COPYRIGHT
347Copyright \(co 2003 Free Software Foundation, Inc.
348.br
349This is free software; see the source for copying conditions. There is NO
350warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
351to the extent permitted by law.
352.SH "SEE ALSO"
353.BR awk (1),
354.BR ed (1),
355.BR grep (1),
356.BR tr (1),
357.BR perlre (1),
358sed.info,
359any of various books on \*(sd,
360.na
361the \*(sd FAQ (http://sed.sf.net/grabbag/tutorials/sedfaq.txt),
362http://sed.sf.net/grabbag/.
363.PP
364The full documentation for
365.B sed
366is maintained as a Texinfo manual. If the
367.B info
368and
369.B sed
370programs are properly installed at your site, the command
371.IP
372.B info sed
373.PP
374should give you access to the complete manual.
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette