File: sed.1

package info (click to toggle)
manpages-ja 0.3-6
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 5,500 kB
  • ctags: 19
  • sloc: sh: 582; makefile: 77
file content (474 lines) | stat: -rw-r--r-- 12,457 bytes parent folder | download | duplicates (2)
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
.\" Copyright (c) 1992, 1993
.\"	The Regents of the University of California.  All rights reserved.
.\"
.\" This code is derived from software contributed to Berkeley by
.\" the Institute of Electrical and Electronics Engineers, Inc.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\"    must display the following acknowledgement:
.\"	This product includes software developed by the University of
.\"	California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\"    may be used to endorse or promote products derived from this software
.\"    without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\"	from: @(#)sed.1	8.2 (Berkeley) 12/30/93
.\"	$Id: sed.1,v 1.4 1994/02/03 23:44:59 cgd Exp $
.\"
.Dd "December 30, 1993"
.Dt SED 1
.Os
.Sh ̾
.Nm sed
.Nd ȥ꡼२ǥ
.Sh 
.Nm sed
.Op Fl an
.Ar command
.Op Ar file ...
.Nm sed
.Op Fl an
.Op Fl e Ar command
.Op Fl f Ar command_file
.Op Ar file ...
.Sh 
.Nm sed
ϡꤵ줿ե롢ե뤬ꤵƤʤȤɸϤɤ߹ߡ
ꤵ줿ޥɥꥹȤ˽äϤѹäѹ̤ɸϤ˽
Фޤ
.Pp
.Nm sed
ؤȤñΥޥɤꤹ뤳ȤǤޤʣΥޥɤꤹȤϡ 
.Fl e
ޤ
.Fl f
ץǹԤޤɤξǤ⡢ϤФƻꤵ줿ޥɤ
ꤵ줿Ǽ¹Ԥޤ
.Pp
ץϰʲΤȤǤ
.Bl -tag -width indent
.It Fl a
̾
.Dq w
ؿΰȤʤեϡΩäƶΥեȤƺޤ
.Fl a
ץꤹ뤳Ȥˤꡢ
.Dq w
ؿϤФŬѤȤޤǡ
եκٱ䤵ޤ
.It Fl e Ar command
ϤФޥ
.Ar command
ŬѤޤ
.It Fl f Ar command_file
ϤФե
.Ar command_file
˵Ҥ줿ޥŬѤޤե
γƥޥɤ1ԤȤ˵Ҥޤ
.It Fl n
ǥեȤǤϡϹԤϡ٤ƤΥޥɤŬѤɸϤ˽
Фޤ
.Fl n
ץϤưػߤŪʽϥޥ
.Ns ( Dq p
) ŬѤ줿ϤΤߤϤޤ
.El
.Pp
.Nm sed
ΥޥɤϰʲηǤ
.sp
.Dl [address[,address]]function[arguments]
.sp
ǽ address  function ˶֤ȤǤޤ
.Pp
̾
.Nm sed
ϡϥեγƹԤԥɤޤ᤺
.Em "ѥ󥹥ڡ"
˥ԡ˥ԡ줿ƤŬ address ĥޥɤ
ŬѤѥ󥹥ڡƤԤͿɸϤؽ񤭽Ф
󥹥ڡõȤư򷫤֤ޤ
.Pp
Ĥδؿϡѥ󥹥ڡΰޤݻǤ
.Em "ۡɥڡ"
ѤޤۡɥڡƤϡʹߤνѤ뤳ȤǤ
ޤ
.Sh "sed  address ɽ"
address λɬܤǤϤޤadderss Ϲֹ(ʣϥե
ФƤֹ̤Ѥޤ)ϤκǸιԤ򼨤ɥ뵭
.Pq Dq $
ƥȥɥ쥹(ڤ국ˤϤޤ줿ɽ)Τ줫Ǥ
.Pp
address ʤޥɤϡϤΤ٤ƤιԤФŬѤޤ
.Pp
1Ĥ address ĥޥɤϡ address ˥ޥå
ˤΤŬѤޤ
.Pp
2Ĥ address ĥޥɤϡ1Ĥ address ˥ޥåԤ
2Ĥ address ˥ޥåԤޤǤΤ٤ƤιԤФŬѤޤ(⤷
2Ĥ address 1Ĥ address ˥ޥåԤ⾮ʹֹ
ֹʤС1Ĥ address ޥåԤΤߤ˥ޥɤŬ
Ѥޤ)򤵤줿ϰϤμιԤ顢1 Ĥ address ˥ޥåԤθ
Ƴޤ
.Pp
᡼ؿ
.Pq Dq !
Ѥ뤳Ȥˤꡢaddress 
򤵤ƤʤϰϤ˥ޥɤŬѤ뤳ȤǤޤ
.Sh "sed ɽ"
.Nm sed
ѤɽϡBasic Regular expression (BRE
.Xr regex 3
򻲾)
ǤBRE ˲ä
.Nm sed
ǤϰʲγĥʤƤޤ
.sp
.Bl -enum -compact
.It
ƥȥɥ쥹ˤơХåå
.Pq Dq \e
Ȳ԰ʳʸɽζ
ڤȤѤ뤳ȤǤޤڤʸľ˥Хåå֤
Ȥǡڤʸƥ˲ᤵ뤳ȤǤޤȤСƥ
ȥɥ쥹 \exabc\exdefx ˤơڤʸ
.Dq x
ǡ2Ĥ
.Dq x 

.Dq x
Ȥʸɽޤäơɽ
.Dq abcxdef
Ȳᤵ

.sp
.It
ץ \en ϡѥ󥹥ڡޤ줿Ԥ˥ޥ
ޤaddress ִޥ˥ƥʲԤޤ뤳
ϤǤޤ
.El
.Pp
.Nm sed
ɽˤϡǥեͤεǽޤ
⤷ɽʤڤΤߤꤵ줿ʤ顢ľѤ줿ɽ
ѤޤľɽȤϡǸ˻Ȥ줿 address ޤִ
ޥɽǤǸȤϼ¹Իν֤Ǥꡢꤵ
줿ޥɤ¤ӤȤϰۤޤȤС
.Dq /abc/s//XXX/
ϥѥ
.Dq abc

.Dq XXX
ִޤ
.Sh "sed δؿ"
ʲΥޥɤΰǤϡǽʺ address [0addr]
[1addr][2addrs] ɽƤޤϡ줾 012 
 address ꤹ뤳ȤǤ뤳Ȥ̣ޤ
.Pp
.Em text
ΥƥȤʣԤϤ뤳ȤǤޤԤľ˥Хåå
֤ȤǡƥȤ˲Ԥޤ뤳ȤǤޤ¾ΥХå
ϼ졢ľʸƥ˲ᤵޤ
.Pp
.Dq r

.Dq w
ؿϡץʥʥե̾Ȥޤե̾ϡ
ؿ̾ΤȤ˶֤ƤꤹɬפޤȤƻꤵ
եϡϥեν򳫻Ϥ˺(ޤϡƤõ)
ޤ
.Pp
.Dq b

.Dq r

.Dq s

.Dq t

.Dq w

.Dq y

.Dq !

.Dq \&:
ؿϡץʥʰȤ뤳Ȥ
Ǥޤʲΰˡɤΰؿ̾ΤȤ˶֤Ƥꤷ
ʤФʤʤҤƤޤ
.Pp
2ĤδؿϰȤƴؿꥹȤȤޤؿꥹȤϡʲη
ԤǶڤ줿
.Nm sed
ؿǤ
.Bd -literal -offset indent
{ function
  function
  ...
  function
}
.Ed
.Pp
.Dq {
˶֤ȤǤޤؿ˶֤ȤǤ
Ǹ
.Dq }
ϡԤľ֤ɬפޤ
.Dq }
ľ˶
ȤǤޤ
.sp
.Bl -tag -width "XXXXXX" -compact
.It [2addr] function-list
򤵤줿ѥ󥹥ڡ˴ؿꥹȤŬѤޤ
.sp
.It [1addr]a\e
.It text
.br
ϹԤɤ߹ľ
.Em text
ɸϤ˽񤭽Фޤ
.sp
.It [2addr]b[lable]
ꤵ줿 label 
.Dq \&:
ؿʬޤlabel ꤵ
ƤʤϡץȤκǸʬޤ
.sp
.It [2addr]c\e
.It text
.br
ѥ󥹥ڡޤaddress ꤵƤʤȡ1Ĥ
ꤵ줿
.Em text
ɸϤ˽񤭽Фޤ2Ĥ address 
ꤵ줿ϡ򤵤줿ϰϤκǸԤˡ text ɸϤ˽񤭽Ф

.sp
.It [2addr]d
ѥ󥹥ڡη֤򳫻Ϥޤ
.sp
.It [2addr]D
ѥ󥹥ڡκǽβԤޤǤʬη֤򳫻Ϥޤ
.sp
.It [2addr]g
ۡɥڡƤѥ󥹥ڡ˥ԡޤ
.sp
.It [2addr]G
ۡɥڡƤѥ󥹥ڡɲäޤ
.sp
.It [2addr]h
ѥ󥹥ڡƤۡɥڡ˥ԡޤ
.sp
.It [2addr]H
ѥ󥹥ڡƤۡɥڡɲäޤ
.sp
.It [1addr]i\e
.It text
.br
ɸϤ
.Em text
񤭽Фޤ
.sp
.It [2addr]l
ѥ󥹥ڡƤɤ褦ʰʲηǽϤޤ
.sp
.Bl -tag -width "carriage-returnXX" -offset indent -compact
.It backslash
\e
.It alert
\ea
.It form-feed
\ef
.It newline
\en
.It carriage-return
\er
.It tab
\et
.It vertical tab
\ev
.El
.Pp
ԲǽʸϡƥХȤȤ
.Dq \e
³ 3  8 ʿǽϤ
ĹԤޤ֤ɽޤޤ֤ʬ
.Dq \e
³Ԥ
ޤƹԤκǸˤ
.Dq $
Ϥޤ
.sp
.It [2addr]n
.Ns ( Fl n
ץˤä) ǥեȤνϤߤƤʤʤ顢
ѥ󥹥ڡƤɸϤ˽񤭽Фѥ󥹥ڡ򼡤Ϲ
֤ޤ
.sp
.It [2addr]N
ѥ󥹥ڡˡϹԤɲäޤΤȤƤȤ
֤˲Ԥߤޤߤιֹ椬Ѳ뤳ȤդƤ
.sp
.It [2addr]p
ѥ󥹥ڡƤɸϤ˽񤭽Фޤ
.sp
.It [2addr]P
ѥ󥹥ڡκǽβԤޤǤƤɸϤ˽񤭽Фޤ
.sp
.It [1addr]q
ץȤλĤ򥹥åפη֤򳫻Ϥ˽λޤ
.sp
.It [1addr]r file
ϹԤɤ߹ľˡե
.Em file
ƤɸϤ˽񤭽Фޤ
.sp
.It [2addr]s/regular expression/replacement/flags
ѥ󥹥ڡǡ regular expression бʬ replacement 
ִޤХååȲ԰ʳʸ򥹥åΤ
뤳ȤǤޤregular expression  replacement ˡƥʶڤʸ
֤ȤϡХåå
³ƶڤʸ֤ޤ
.Pp
replacement Υѥ
.Pq Dq &
ϡregular expression ˥ޥåʸ
ִޤ
.Dq &

.Dq \e
֤Ȥǡü
.Dq &
βػ
뤳ȤǤޤ
.Dq \e#
.Ns ( Dq #
Ͽ) ϡ regular expression 
.Dq \e(...\e)
ǰϤޤ줿
ʬִޤ(re_format(7) )
.Pp
replacement ˲Ԥޤ뤳ȤǡϹԤʬ䤹뤳ȤǤޤ
Ԥľ
.Dq \e
֤Ȥǡreplacement ˲Ԥޤ뤳ȤǤ
ޤ
.Pp
s ؿ
.Em flags
ˤϡʲΤΤʣǤޤ
.Bl -tag -width "XXXXXX" -offset indent
.It "0 ... 9"
ѥ󥹥ڡ N ܤޤǥޥåƤ replacement ִޤ
.It g
pattern ˥ޥå٤ƤƤ replacementִޤ
.It p
ִԤ줿顢ѥ󥹥ڡƤɸϤ˽񤭽Фޤ
⤷ִƤִΤΤƱǤִԤ줿Ȥߤʤޤ
.It w Em file
⤷ִԤ줿ʤ顢ѥ󥹥ڡƤե
.Em file
˽Ϥ
⤷ִƤִΤΤƱǤִԤ줿Ȥߤʤޤ
.El
.sp
.It [2addr]t [label]
ϹԤɤ߹ޤƤ顢뤤
.Dq t
ޥɤ¹ԤƤ顢ִ
ԤƤСꤷ label 
.Dq \&:
ޥɤʬ롣label 
ꤵƤʤϡץȤκǸʬ롣
.sp
.It [2addr]w Em file
ѥ󥹥ڡƤե
.Em file
ɲä롣
.sp
.It [2addr]x
ѥ󥹥ڡȥۡɥڡƤ򴹤롣
.sp
.It [2addr]y/string1/string2/
.Em string1
˸ѥ󥹥ڡʸ
.Em string2
б
ʸִ롣ȤС`y/abc/ABC/' ϥѥ󥹥ڡʸ
abc ʸִ롣
ХååȲ԰ʳΤ٤ƤʸڤȤ
Ѥ뤳ȤǤ롣
.Em string1

.Em stirng2
Ǥϡ`\e' ľβ԰ʳ
ʸϥƥ˲ᤵ졢`\en' ϲԤȲᤵޤ
.sp
.It [2addr]!function
.It [2addr]!function-list
ؿޤϴؿꥹȤ address 򤵤ƤʤԤŬѤ롣
.sp
.It [0addr]:label
δؿϲԤʤ
.Dq b

.Dq t
Ѥ٥롣
.sp
.It [1addr]=
ֹȲԤɸϤ˽񤭽Ф
.sp
.It [0addr]
Ԥ̵뤵롣
.sp
.It [0addr]#
.Dq #
Ȥʹߤʸ̵뤵(ȤȤư)Ƭ 2 
ʸ `#n' ξ硢ǥեȤνϤػߤ롣ϡޥɥ饤

.Fl n
ץꤷǤ
.El
.Pp
.Nm sed
Сλơ 0 򡢼Ԥ 0 礭
λơ֤ޤ
.Sh Ϣ
.Xr awk 1 ,
.Xr ed 1 ,
.Xr grep 1 ,
.Xr regex 3 ,
.Xr re_format 7
.Sh 
.Nm sed

.At v7
ɲäޤ
.Sh ɸ

.Nm sed
δؿ
.St -p1003.2
ΥѥåȤȤʤäƤϤǤ