OSDN Git Service

Convert release and draft pages to UTF-8.
[linuxjm/jm.git] / manual / GNU_sed / draft / man1 / sed.1
1 .\"
2 .\" sed.1 - the *roff document processor source for the sed manual
3 .\"
4 .\" This file is part of GNU sed.
5 .\" Copyright (C) 1998 Free Software Foundation, Inc.
6 .\"
7 .\" This program is free software; you can redistribute it and/or modify
8 .\" it under the terms of the GNU General Public License as published by
9 .\" the Free Software Foundation; either version 2, or (at your option)
10 .\" any later version.
11 .\"
12 .\" This program is distributed in the hope that it will be useful,
13 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
14 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 .\" GNU General Public License for more details.
16 .\"
17 .\" You should have received a copy of the GNU General Public License
18 .\" along with this program; if not, write to the Free Software
19 .\" Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20 .\"
21 .\" Japanese Version Copyright (c) 2001 NAKANO Takeo all rights reserved.
22 .\" Translated Mon 7 May 2001 by NAKANO Takeo <nakano@apm.seikei.ac.jp>
23 .\"
24 .TH SED 1 "1998-05-07" "GNU Project"
25 .ds sd \fIsed\fP
26 .\"O .ds Sd \fISed\fP
27 .\"O .SH NAME
28 .\"O sed \- a Stream EDitor
29 .SH 名前
30 sed \- ストリームエディタ
31 .\"O .SH SYNOPSIS
32 .SH 書式
33 .nf
34 sed [-n] [-V] [--quiet] [--silent] [--version] [--help]
35     [-e script] [--expression=script]
36     [-f script-file] [--file=script-file]
37     [script-if-no-other-script]
38     [file...]
39 .fi
40 .\"O .SH DESCRIPTION
41 .SH 説明
42 .\"O \*(Sd is a stream editor.
43 .\"O A stream editor is used to perform basic text
44 .\"O transformations on an input stream
45 .\"O (a file or input from a pipeline).
46 .\"O While in some ways similar to an editor which
47 .\"O permits scripted edits (such as \fIed\fP),
48 .\"O \*(sd works by making only one pass over the
49 .\"O input(s), and is consequently more efficient.
50 .\"O But it is \*(sd's ability to filter text in a pipeline
51 .\"O which particularly distinguishes it from other types of
52 .\"O editors.
53 \*(sd はストリームエディタである。
54 ストリームエディタは、入力ストリーム
55 (ファイルまたはパイプラインからの入力)
56 に対して基本的なテキスト変換を行うために用いられる。
57 \*(sd は
58 編集スクリプトを使える (\fIed\fP のような) エディタと
59 いろいろな面で似ているが、
60 \*(sd は入力に対して 1 パスだけで動作するので、より効率的である。
61 また \*(sd はパイプラインのテキストに対してフィルタ動作を行うことができ、
62 この点は他のタイプのエディタとはっきり違う。
63
64 .\"O .SH OPTIONS
65 .SH オプション
66 .\"O \*(Sd may be invoked with the following command-line options:
67 \*(sd の起動時には以下のコマンドラインオプションを指定できる。
68 .TP
69 .B -V
70 .TP
71 .B --version
72 .\"O Print out the version of sed that is being run and a copyright notice,
73 .\"O then exit.
74 sed のバージョン・著作権表示を出力し、終了する。
75 .TP
76 .B -h
77 .TP
78 .B --help
79 .\"O Print a usage message briefly summarizing these command-line options
80 .\"O and the bug-reporting address,
81 .\"O then exit.
82 コマンドラインオプションを簡単にまとめた利用法と
83 バグレポート先のアドレスを出力し、終了する。
84 .TP
85 .B -n
86 .TP
87 .B --quiet
88 .TP
89 .B --silent
90 .\"O By default, \*(sd will print out the pattern space
91 .\"O at the end of each cycle through the script.
92 .\"O These options disable this automatic printing,
93 .\"O and \*(sd will only produce output when explicitly told to
94 .\"O via the
95 .\"O .B p
96 .\"O command.
97 デフォルトでは、
98 \*(sd はスクリプトの各サイクルの最後でパターンスペースの内容を出力する。
99 これらのオプションを指定するとこの自動的な出力が行われなくなり、
100 .B p
101 コマンドで出力することを指定された場合に限って
102 \*(sd は出力を生成する。
103 .TP
104 .B -e \fIscript\fP
105 .TP
106 .BI --expression= script
107 .\"O Add the commands in
108 .\"O .I script
109 .\"O to the set of commands to be run while processing the input.
110 .I script
111 のコマンドを、入力の処理中に行われるコマンドセットに追加する。
112 .TP
113 .B -f \fIscript-file\fP
114 .TP
115 .BI --file= script-file
116 .\"O Add the commands contained in the file
117 .\"O .I script-file
118 .\"O to the set of commands to be run while processing the input.
119 ファイル
120 .I script-file
121 に含まれるコマンドを、入力の処理中に行われるコマンドセットに追加する。
122 .PP
123 .\"O If no
124 .\"O .BR -e , -f , --expression ,
125 .\"O or
126 .\"O .B --file
127 .\"O options are given on the command-line,
128 .\"O then the first non-option argument on the command line is
129 .\"O taken to be the
130 .\"O .I script
131 .\"O to be executed.
132 .BR -e ", " -f ", " --expression ", " --file
133 などのオプションがコマンドラインから全く与えられなかった場合は、
134 コマンドラインの引き数のうち、オプションでない最初のものが
135 .I script
136 として受け取られ、実行される。
137 .PP
138 .\"O If any command-line parameters remain after processing the above,
139 .\"O these parameters are interpreted as the names of input files to
140 .\"O be processed.
141 .\"O A file name of
142 .\"O .B -
143 .\"O refers to the standard input stream.
144 .\"O The standard input will processed if no file names are specified.
145 以上のコマンドラインパラメータを処理したあとに引き数が残った場合は、
146 それらは処理対象となる入力ファイルのファイル名と解釈される。
147 .B -
148 というファイル名は、標準入力ストリームを参照する。
149 ファイル名が全く指定されなかった場合は標準入力を処理する。
150
151 .\"O .SH
152 .\"O Command Synopsis
153 .SH コマンドの文法
154 .\"O This is just a brief synopsis of \*(sd commands to serve as
155 .\"O a reminder to those who already know sed;
156 .\"O other documentation (such as the texinfo document)
157 .\"O must be consulted for fuller descriptions.
158 これは \*(sd コマンドのごく簡単な文法で、
159 既に sed を知っている人に対する備忘録程度のものである。
160 完全な記述を求める場合は他の文書 (texinfo 文書など) にあたること。
161 .\"O .SS
162 .\"O Zero-address ``commands''
163 .SS アドレスを取らないコマンド
164 .TP
165 .RI :\  label
166 .\"O Label for
167 .\"O .B b
168 .\"O and
169 .\"O .B t
170 .\"O commands.
171 .B b
172 コマンドと
173 .B t
174 コマンド用のラベル。
175 .TP
176 .RI # comment
177 .\"O The comment extends until the next newline (or the end of a
178 .\"O .B -e
179 .\"O script fragment).
180 次の改行文字まで (あるいは
181 .B -e
182 スクリプトフラグメントの末尾まで) をコメントとして取り扱う。
183 .TP
184 }
185 .\"O The closing bracket of a { } block.
186 { } ブロックの閉じ括弧。
187 .\"O .SS
188 .\"O Zero- or One- address commands
189 .SS アドレスを 0 または 1 個とるコマンド
190 .TP
191 =
192 .\"O Print the current line number.
193 現在の行番号を表示する。
194 .TP
195 a \e
196 .TP
197 .I text
198 .\"O Append
199 .\"O .IR text ,
200 .\"O which has each embedded newline preceeded by a backslash.
201 .I text
202 を追加する。
203 .I text
204 に改行を含めたい場合は、その前にバックスラッシュを置く。
205 .TP
206 i \e
207 .TP
208 .I text
209 .\"O Insert
210 .\"O .IR text ,
211 .\"O which has each embedded newline preceeded by a backslash.
212 .I text
213 を挿入する。
214 .I text
215 に改行を含めたい場合は、その前にバックスラッシュを置く。
216 .TP
217 q
218 .\"O Immediately quit the \*(sd script without processing
219 .\"O any more input,
220 .\"O except that if auto-print is not diabled
221 .\"O the current pattern space will be printed.
222 これ以上入力の処理を行わず、ただちに \*(sd スクリプトの処理を終了する。
223 ただし auto-print が diable されていなければ、
224 カレントのパターンスペースが出力される。
225 .TP
226 .RI r\  filename
227 .\"O Append text read from
228 .\"O .IR filename .
229 テキストを
230 .I filename
231 から読んで追加する。
232 .\"O .SS
233 .\"O Commands which accept address ranges
234 .SS アドレス範囲をとりうるコマンド
235 .TP
236 {
237 .\"O Begin a block of commands (end with a }).
238 コマンドブロックの開始 (} で終了する)。
239 .TP
240 .RI b\  label
241 .\"O Branch to
242 .\"O .IR label ;
243 .\"O if
244 .\"O .I label
245 .\"O is omitted, branch to end of script.
246 .I label
247 に分岐する。
248 .I label
249 が省略された場合は、スクリプトの末尾に分岐する。
250 .TP
251 .RI t\  label
252 .\"O If a s/// has done a successful substitution since the
253 .\"O last input line was read and since the last t command,
254 .\"O then branch to
255 .\"O .IR label ;
256 .\"O if
257 .\"O .I label
258 .\"O is omitted, branch to end of script.
259 最後に入力行が読まれ、最後に t コマンドが行われて以降に
260 s/// が成功していれば、
261 .I label
262 に分岐する。
263 .I label
264 が省略された場合は、スクリプトの末尾に分岐する。
265 .TP
266 c \e
267 .TP
268 .I text
269 .\"O Replace the selected lines with
270 .\"O .IR text ,
271 .\"O which has each embedded newline preceeded by a backslash.
272 選択した行を
273 .I text
274 で置換する。
275 .I text
276 に改行を含めたい場合は、その前にバックスラッシュを置く。
277 .TP
278 d
279 .\"O Delete pattern space.
280 .\"O Start next cycle.
281 パターンスペースを削除する。
282 次のサイクルを開始する。
283 .TP
284 D
285 .\"O Delete up to the first embedded newline in the pattern space.
286 .\"O Start next cycle, but skip reading from the input
287 .\"O if there is still data in the pattern space.
288 パターンスペースの最初の改行までを削除する。
289 次のサイクルを開始するが、
290 パターンスペースにまだデータが残っていたら、
291 入力からの読み込みをスキップする。
292 .TP
293 h H
294 .\"O Copy/append pattern space to hold space.
295 パターンスペースをホールドスペースにコピー/追加する。
296 .TP
297 g G
298 .\"O Copy/append hold space to pattern space.
299 ホールドスペースをパターンスペースにコピー/追加する。
300 .TP
301 x
302 .\"O Exchange the contents of the hold and pattern spaces.
303 ホールドスペースとパターンスペースの内容を交換する。
304 .TP
305 l
306 .\"O List out the current line in a ``visually unambiguous'' form.
307 現在の行を「視覚的に紛れのない」形式でリストする。
308 .TP
309 n N
310 .\"O Read/append the next line of input into the pattern space.
311 入力の次の行をパターンスペースに読み込む/追加する。
312 .TP
313 p
314 .\"O Print the current pattern space.
315 現在のパターンスペースを出力する。
316 .TP
317 P
318 .\"O Print up to the first embedded newline of the current pattern space.
319 現在のパターンスペースの最初の改行までを出力する。
320 .TP
321 .RI s/ regexp / replacement /
322 .\"O Attempt to match
323 .\"O .I regexp
324 .\"O against the pattern space.
325 パターンスペースに対して
326 .I regexp
327 のマッチを試みる。
328 .\"O If successful, replace that portion matched
329 .\"O with
330 .\"O .IR replacement .
331 マッチに成功すると、マッチした部分を
332 .I replacement
333 に置換する。
334 .\"O The
335 .\"O .I replacement
336 .\"O may contain the special character
337 .\"O .B &
338 .\"O to refer to that portion of the pattern space which matched,
339 .\"O and the special escapes \e1 through \e9 to refer to the
340 .\"O corresponding matching sub-expressions in the
341 .\"O .IR regexp .
342 .I replacement
343 は特殊文字である
344 .B &
345 を含むことができ、これはパターンスペースのマッチした部分を参照する。
346 また \e1 から \e9 までの特殊エスケープを含むこともでき、
347 これは
348 .I regexp
349 の副表現 (sub-expression) にマッチした部分をそれぞれ参照する。
350 .TP
351 .RI w\  filename
352 .\"O .I filename
353 .\"O Write the current pattern space to
354 .\"O .IR filename .
355 現在のパターンスペースを
356 .I filename
357 に書く。
358 .TP
359 .RI y/ source / dest /
360 .\"O Transliterate the characters in the pattern space which appear in
361 .\"O .I source
362 .\"O to the corresponding character in
363 .\"O .IR dest .
364 パターンスペースにある文字のうち、
365 .I source
366 にあるものを、
367 .I dest
368 の同じ位置にある文字に交換する。
369 .\"O .SH
370 .\"O Addresses
371 .SH アドレス
372 .\"O \*(Sd commands can be given with no addresses, in which
373 .\"O case the command will be executed for all input lines;
374 .\"O with one address, in which case the command will only be executed
375 .\"O for input lines which match that address; or with two
376 .\"O addresses, in which case the command will be executed
377 .\"O for all input lines which match the inclusive range of
378 .\"O lines starting from the first address and continuing to
379 .\"O the second address.
380 \*(sd のコマンドはアドレスを指定せずに与えることもでき、
381 この場合そのコマンドはすべての入力行に対して実行される。
382 アドレスをひとつ与えると、
383 コマンドはそのアドレスにマッチした入力行に対してのみ実行される。
384 2 つのアドレスを与えると、最初のアドレスにマッチした行から、
385 2 番目のアドレスにマッチした行に至る範囲 (両マッチ行を含む)
386 にあるすべての行に対して実行される。
387 .\"O Three things to note about address ranges:
388 .\"O the syntax is
389 .\"O .IR addr1 , addr2
390 .\"O (i.e., the addresses are separated by a comma);
391 .\"O the line which
392 .\"O .I addr1
393 .\"O matched will always be accepted,
394 .\"O even if
395 .\"O .I addr2
396 .\"O selects an earlier line;
397 .\"O and if
398 .\"O .I addr2
399 .\"O is a
400 .\"O .IR regexp ,
401 .\"O it will not be tested against the line that
402 .\"O .I addr1
403 .\"O matched.
404 アドレスの範囲指定については 3 つのことを注意しておく。
405 まず指定方法は
406 .IR addr1 , addr2
407 である (つまりアドレスをコンマで区切る)。
408 .I addr1
409 にマッチした行は、たとえ
410 .I addr2
411 がより前の行にマッチした場合でも、常に処理対象となる。
412 .I addr2
413
414 .I regexp
415 (正規表現) の場合には、
416 .I addr1
417 にマッチした行に対しては
418 .I addr2
419 のマッチは行われない。
420 .PP
421 .\"O After the address (or address-range),
422 .\"O and before the command, a
423 .\"O .B !
424 .\"O may be inserted,
425 .\"O which specifies that the command shall only be
426 .\"O executed if the address (or address-range) does
427 .\"O .B not
428 .\"O match.
429 アドレス (あるいはアドレス範囲) とコマンドの間には
430 .B !
431 を挟むことができる。この場合は、アドレス (あるいはアドレス範囲) が
432 \fBマッチしなかった\fP行に対してのみコマンドが実行される。
433 .PP
434 .\"O The following address types are supported:
435 以下のアドレスタイプがサポートされている。
436 .TP
437 .I number
438 .\"O Match only the specified line
439 .\"O .IR number .
440 .I number
441 で指定した行だけにマッチする。
442 .TP
443 .IR first ~ step
444 .\"O Match every
445 .\"O .IR step 'th
446 .\"O line starting with line
447 .\"O .IR first .
448 .\"O For example, ``sed -n 1~2p'' will print all the odd-numbered lines in
449 .\"O the input stream, and the address 2~5 will match every fifth line,
450 .\"O starting with the second.
451 .\"O (This is a GNU extension.)
452 .I first
453 行からはじまる
454 .I step
455 行おきの行にマッチする。例えば ``sed -n 1~2p'' は
456 入力行のうち奇数行を表示し、アドレスを 2~5 にすると、
457 第 2 行から 5 行おきに表示する (これは GNU の拡張である)。
458 .TP
459 $
460 .\"O Match the last line.
461 最終行にマッチする。
462 .TP
463 .RI / regexp /
464 .\"O Match lines matching the regular expression
465 .\"O .IR regexp .
466 正規表現
467 .I regexp
468 にマッチした行にマッチする。
469 .TP
470 .BI \fR\e\fPc regexp c
471 .\"O Match lines matching the regular expression
472 .\"O .IR regexp .
473 .\"O The
474 .\"O .B c
475 .\"O may be any character.
476 正規表現
477 .I regexp
478 にマッチした行にマッチする。
479 文字
480 .B c
481 は何でもよい。
482 .\"O .SH
483 .\"O Regular expressions
484 .SH 正規表現
485 .\"O POSIX.2 BREs
486 .\"O .I should
487 .\"O be supported, but they aren't completely yet.
488 .\"O The
489 .\"O .B \en
490 .\"O sequence in a regular expression matches the newline character.
491 .\"O There are also some GNU extensions.
492 .\"O [XXX FIXME: more needs to be said.
493 .\"O At the very least, a reference to another document which
494 .\"O describes what is supported should be given.]
495 POSIX.2 BRE
496 をサポートすべきであるが、まだ完全にはサポートできていない。
497 正規表現内部の
498 .B \en
499 シーケンスは改行文字にマッチする。
500 GNU 拡張も存在する。
501 [要修正: より詳細を記述する必要がある。
502 少なくとも、何がサポートされているかを述べた、
503 他の文書へのリファレンスが必要である]
504 .\"O .SH
505 .\"O Miscellaneous notes
506 .SH その他の注意
507 .\"O This version of sed supports a
508 .\"O .RB \e <newline>
509 .\"O sequence in
510 .\"O all regular expressions, the
511 .\"O .I replacement
512 .\"O part of a substitute (s) command, and in the
513 .\"O .I source
514 .\"O and
515 .\"O .I dest
516 .\"O parts of a transliterate (y) command.
517 .\"O The \e is stripped, and the newline is kept.
518 このバージョンの sed は、
519 あらゆる正規表現の内部・置換コマンドの
520 .I replacement
521 の内部・文字交換 (y) コマンドの
522 .I source
523 および
524 .I dest
525 の内部のいずれにおいても、
526 .RB \e <newline>
527 というシーケンスが使える。
528 .\"O .SH
529 .\"O SEE ALSO
530 .SH 関連項目
531 .BR awk (1),
532 .BR ed (1),
533 .BR expr (1),
534 .BR emacs (1),
535 .BR perl (1),
536 .BR tr (1),
537 .BR vi (1),
538 .BR regex (5)
539 .\"O [well, one
540 .\"O .I ought
541 .\"O to be written... XXX],
542 [うーん、書かないとダメですねえ]
543 【訳注: LDP には
544 .BR regex (7)
545 があります】,
546 sed.info,
547 .\"O any of various books on \*(sd,
548 \*(sd に関する様々な本のいずれか,
549 .na
550 the \*(sd FAQ (http://www.wollery.demon.co.uk/sedtut10.txt,
551 http://www.ptug.org/sed/sedfaq.htm).
552 .\"O .SH
553 .\"O BUGS
554 .SH バグ
555 .PP
556 .\"O E-mail bug reports to
557 .\"O .BR bug-gnu-utils@gnu.org .
558 .\"O Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.
559 バグレポートは
560 .B bug-gnu-utils@gnu.org
561 まで送って下さい。
562 「Subject:」フィールドのどこかに
563 「sed」という単語を入れるようにして欲しい。