Introduction
Introduction Statistics Contact Development Disclaimer Help
sed.1 - sbase - suckless unix tools
git clone git://git.suckless.org/sbase
Log
Files
Refs
README
LICENSE
---
sed.1 (4496B)
---
1 .Dd October 8, 2015
2 .Dt SED 1
3 .Os sbase
4 .Sh NAME
5 .Nm sed
6 .Nd stream editor
7 .Sh SYNOPSIS
8 .Nm
9 .Op Fl nrE
10 .Ar script
11 .Op Ar file ...
12 .Nm
13 .Op Fl nrE
14 .Fl e Ar script
15 .Op Fl e Ar script
16 .Ar ...
17 .Op Fl f Ar scriptfile
18 .Ar ...
19 .Op Ar file ...
20 .Nm
21 .Op Fl nrE
22 .Op Fl e Ar script
23 .Ar ...
24 .Fl f Ar scriptfile
25 .Op Fl f Ar scriptfile
26 .Ar ...
27 .Op Ar file ...
28 .Sh DESCRIPTION
29 .Nm
30 reads line oriented output from
31 .Ar file
32 or stdin, applies the editing commands supplied by
33 .Ar script
34 or
35 .Ar scriptfile
36 and writes the edited stream to stdout.
37 .Sh OPTIONS
38 .Bl -tag -width Ds
39 .It Fl n
40 Suppress default printing at the end of each cycle.
41 .It Fl r E
42 Use extended regular expressions
43 .It Fl e Ar script
44 Append
45 .Ar script
46 to the list of editing commands.
47 .It Fl f Ar scriptfile
48 Append the commands from
49 .Ar scriptfile
50 to the list of editing commands.
51 .El
52 .Sh EXTENDED DESCRIPTION
53 Editing commands take the form:
54 .Pp
55 [address[,address]]function
56 .Pp
57 Commands can be separated by ';' or by a new line.
58 .Pp
59 Multiple functions for the specified address (or address-range) can be e…
60 in blocks with '{' and '}':
61 .Pp
62 [address[,address]] { function ; function }
63 .Pp
64 .Ss Addresses
65 Addresses are either blank, a positive decimal integer denoting a line
66 number, the character '$' denoting the last line of input, or a regular
67 expression (in the format
68 .No / Ns
69 .Ar regexp Ns /).
70 A command with no addresses matches every line, one address matches
71 individual lines, and two addresses matches a range of lines from the
72 first to the second address inclusive.
73 .Pp
74 The character '!' may be appended after the addresses,
75 in which case the function is executed only if the addresses
76 .Em don't
77 match.
78 .Pp
79 .Ss Functions
80 .Bl -tag -width Ds
81 .It Ar a Op Ar text
82 Append text to output after end of current cycle.
83 .It Ar b Op Ar label
84 Branch to label.
85 If no label is provided branch to end of script.
86 .It Ar c Op Ar text
87 Change.
88 Delete addressed range and output text after end of current cycle.
89 .It Ar d
90 Delete pattern space and begin next cycle.
91 .It Ar D
92 Delete pattern space up to and including first newline and begin new
93 cycle without reading input.
94 If there is no newline, behave like d.
95 .It Ar g
96 Get.
97 Replace the pattern space with the hold space.
98 .It Ar G
99 Get.
100 Append a newline and the hold space to the pattern space.
101 .It Ar h
102 Hold.
103 Replace the hold space with the pattern space.
104 .It Ar H
105 Hold.
106 Append a newline and the pattern space to the hold space.
107 .It Ar i Op Ar text
108 Insert text in output.
109 .It Ar l
110 List? Write the pattern space replacing known non printing characters wi…
111 backslash escaped versions (\\\\, \\a, \\b, \\f, \\r, \\t, \\v).
112 Print bad UTF-8 sequences as \\ooo where ooo is a three digit octal
113 number.
114 Mark end of lines with '$'.
115 .It Ar n
116 Next.
117 Write pattern space (unless
118 .Fl n ) ,
119 read next line into pattern space, and continue current cycle.
120 If there is no next line, quit.
121 .It Ar N
122 Next.
123 Read next line, append newline and next line to pattern space, and
124 continue cycle.
125 If there is no next line, quit without printing current pattern space.
126 .It Ar p
127 Print current pattern space.
128 .It Ar P
129 Print current pattern space up to first newline.
130 .It Ar q
131 Quit.
132 .It Ar r file
133 Read file and write contents to output.
134 .It Ar s/re/text/flags
135 Find occurences of regular expression re in the pattern space and
136 replace with text.
137 A '&' in text is replaced with the entire match.
138 A \\d where d is a decimal digit 1-9 is replaced with the corresponding
139 match group from the regular expression.
140 \\n represents a newline in both the regular expression and replacement
141 text.
142 A literal newline in the replacement text must be preceded by a \\.
143 .Pp
144 Flags are
145 .Bl -tag -width Ds
146 .It Ar n
147 A positive decimal number denoting which match in the pattern space
148 to replace.
149 .It Ar g
150 Global.
151 Replace all matches in the pattern space.
152 .It Ar p
153 Print the pattern if a replacement was made.
154 .It Ar w file
155 Write the pattern space to file if a replacement was made.
156 .El
157 .It Ar t Op Ar label
158 Test.
159 Branch to corresponding label if a substitution has been made since the
160 last line was read or last t command was executed.
161 If no label is provided branch to end of script.
162 .It Ar w file
163 Write pattern space to file.
164 .It Ar x
165 Exchange hold space and pattern space.
166 .It Ar y/set1/set2/
167 Replace each occurrence of a character from set 1 with the corresponding
168 character from set 2.
169 .It Ar :label
170 Create a label for b and t commands.
171 .It Ar #comment
172 The comment extends until the next newline.
173 .It Ar =
174 Write current input line number to output.
175 .El
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.