OSDN Git Service

6ab7a180f7420ad5ba9f542a4e2f68cc75bc7537
[linuxjm/jm.git] / manual / GNU_grep / draft / man1 / grep.1
1 .\" GNU grep man page
2 .if !\n(.g \{\
3 .       if !\w|\*(lq| \{\
4 .               ds lq ``
5 .               if \w'\(lq' .ds lq "\(lq
6 .       \}
7 .       if !\w|\*(rq| \{\
8 .               ds rq ''
9 .               if \w'\(rq' .ds rq "\(rq
10 .       \}
11 .\}
12 .
13 .ie \n[.g] .mso www.tmac
14 .el \{\
15 . de MTO
16 \\$2 \(laemail: \\$1 \(ra\\$3
17 ..
18 . de URL
19 \\$2 \(laURL: \\$1 \(ra\\$3
20 ..
21 .\}
22 .
23 ..
24 .\"
25 .\" About Japanese translation
26 .\"   The original version was contributed to Linux JM project 
27 .\"     by FreeBSD jpman Project.
28 .\"     It contained these lines:
29 .\"       %FreeBSD: src/gnu/usr.bin/grep/grep.1,v 1.16.2.3 2001/11/27 08:25:45 ru Exp %
30 .\"       .Id %Id: grep.1,v 1.3 2000/06/09 21:58:50 horikawa Exp %
31 .\"   Updated and Modified (grep-2.6.3) Thu Nov 11 11:44:47 JST 2010
32 .\"     by Chonan Yoichi <cyoichi@maple.ocn.ne.jp>
33 .\"   Updated and Modified (grep-2.27) Thu Feb 25 2017
34 .\"     by Masakazu Takahashi <emasaka@gmail.com>
35 .\"
36 .TH GREP 1 \*(Dt "GNU grep 2.27" "User Commands"
37 .hy 0
38 .
39 .\"O .SH NAME
40 .SH 名前
41 .\"O grep, egrep, fgrep \- print lines matching a pattern
42 grep, egrep, fgrep \- パターンにマッチする行を表示する
43 .
44 .\"O .SH SYNOPSIS
45 .SH 書式
46 .B grep
47 .RI [ OPTIONS ]
48 .I PATTERN
49 .RI [ FILE .\|.\|.]
50 .br
51 .B grep
52 .RI [ OPTIONS ]
53 .RB [ \-e
54 .I PATTERN
55 |
56 .B \-f
57 .IR FILE ]
58 .RI [ FILE .\|.\|.]
59 .
60 .\"O .SH DESCRIPTION
61 .SH 説明
62 .\"O .B grep
63 .\"O searches the named input
64 .\"O .IR FILE s
65 .\"O for lines containing a match to the given
66 .\"O .IR PATTERN .
67 .\"O If no files are specified, or if the file
68 .\"O .RB "\*(lq" \- "\*(rq"
69 .\"O is given,
70 .\"O .B grep
71 .\"O searches standard input.
72 .\"O By default,
73 .\"O .B grep
74 .\"O prints the matching lines.
75 .B grep
76
77 .IR FILE
78 で名前を指定されたファイルを検索して、与えられた
79 .IR PATTERN
80 にマッチする部分を含む行を探します。
81 ファイルが指定されていない場合や、
82 ファイル名の代わりに 1 個のマイナス記号
83 .RB "\*(lq" \- "\*(rq"
84 が指定されている場合は、
85 .B grep
86 は標準入力から検索します。
87 デフォルトでは、
88 .B grep
89 はマッチした行を表示します。
90 .PP
91 .\"O In addition, two variant programs
92 .\"O .B egrep
93 .\"O and
94 .\"O .B fgrep
95 .\"O are the same as
96 .\"O .BR "grep\ \-E" ,
97 .\"O and
98 .\"O .BR "grep\ \-F" ,
99 .\"O respectively.
100 さらに、兄弟プログラム
101 .B egrep
102
103 .B fgrep
104 は、それぞれ
105 .BR "grep\ \-E"
106
107 .BR "grep\ \-F"
108 と同じです。
109 .\"O These variants are deprecated, but are provided for backward compatibility.
110 .\"O .
111 これらの兄弟プログラムは非推奨ですが、後方互換性のために用意されています。
112 .
113 .\"O .SH OPTIONS
114 .SH オプション
115 .\"O .SS "Generic Program Information"
116 .SS "プログラムについての一般情報"
117 .TP
118 .B \-\^\-help
119 .\"O Output a usage message and exit.
120 使用法を出力して終了します。
121 .TP
122 .BR \-V ", " \-\^\-version
123 .\"O Output the version number of
124 .\"O .B grep
125 .\"O and exit.
126 .B grep
127 のバージョン番号を出力して終了します。
128 .\"O .SS "Matcher Selection"
129 .SS "正規表現の選択"
130 .TP
131 .BR \-E ", " \-\^\-extended\-regexp
132 .\"O Interpret
133 .\"O .I PATTERN
134 .\"O as an extended regular expression (ERE, see below).
135 .I PATTERN
136 を拡張正規表現 (ERE) として扱います (下記参照)。
137 .TP
138 .BR \-F ", " \-\^\-fixed\-strings
139 .\"O Interpret
140 .\"O .I PATTERN
141 .\"O as a list of fixed strings (instead of regular expressions),
142 .\"O separated by newlines,
143 .\"O any of which is to be matched.
144 .I PATTERN
145 を改行で区切られた固定文字列 (正規表現のかわりに) のリストとして扱い、
146 その文字列のいずれかとマッチするかどうかを調べます。
147 .TP
148 .BR \-G ", " \-\^\-basic\-regexp
149 .\"O Interpret
150 .\"O .I PATTERN
151 .\"O as a basic regular expression (BRE, see below).
152 .\"O This is the default.
153 .I PATTERN
154 を基本正規表現 (BRE) として扱います (下記参照)。これがデフォルトです。
155 .TP
156 .BR \-P ", " \-\^\-perl\-regexp
157 .\"O Interpret the pattern as a Perl-compatible regular expression (PCRE).
158 .\"O This is highly experimental and
159 .\"O .B "grep \-P"
160 .\"O may warn of unimplemented features.
161 パターンを Perl 互換の正規表現 (PCRE) として扱います。
162 きわめて実験的なものなので、
163 .B "grep \-P"
164 を使うと、その機能は実装されていませんという
165 警告が出るかもしれません。
166 .\"O .SS "Matching Control"
167 .SS "マッチングの制御"
168 .TP
169 .BI \-e " PATTERN" "\fR,\fP \-\^\-regexp=" PATTERN
170 .\"O Use
171 .\"O .I PATTERN
172 .\"O as the pattern.
173 .I PATTERN
174 をパターンとして指定します。
175 .\"O If this option is used multiple times or is combined with the
176 .\"O .B \-f
177 .\"O .RB ( \-\-file )
178 .\"O option, search for all patterns given.
179 このオプションを複数回使ったときや、
180 .B \-f
181 .RB ( \-\-file )
182 オプションと組み合わせたときは、与えられたすべてのパターンを検索します。
183 .\"O This option can be used to protect a pattern beginning with \*(lq\-\*(rq.
184 このオプションは、ハイフン  \*(lq\-\*(rq
185 で始まるパターンを保護するのにも使えます。
186 .TP
187 .BI \-f " FILE" "\fR,\fP \-\^\-file=" FILE
188 .\"O Obtain patterns from
189 .\"O .IR FILE ,
190 .\"O one per line.
191 パターンを
192 .IR FILE
193 から 1 行 1 パターンとして読み込みます。
194 .\"O If this option is used multiple times or is combined with the
195 .\"O .B \-e
196 .\"O .RB ( \-\-regexp )
197 .\"O option, search for all patterns given.
198 このオプションを複数回使ったときや、
199 .B \-e
200 .RB ( \-\-regexp )
201 オプションと組み合わせたときは、与えられたすべてのパターンを検索します。
202 .\"O The empty file contains zero patterns, and therefore matches nothing.
203 空のファイルはパターンを含まないので、何にもマッチしません。
204 .TP
205 .BR \-i ", " \-\^\-ignore\-case
206 .\"O Ignore case distinctions in both the
207 .\"O .I PATTERN
208 .\"O and the input files.
209 .I PATTERN
210 と入力ファイルの双方で、アルファベットの大文字と小文字を
211 区別しないようにします。
212 .TP
213 .BR \-v ", " \-\^\-invert\-match
214 .\"O Invert the sense of matching, to select non-matching lines.
215 マッチの意味を逆にして、マッチしない行を抜き出して表示します。
216 .TP
217 .BR \-w ", " \-\^\-word\-regexp
218 .\"O Select only those lines containing matches that form whole words.
219 .\"O The test is that the matching substring must either be at the
220 .\"O beginning of the line, or preceded by a non-word constituent
221 .\"O character.
222 .\"O Similarly, it must be either at the end of the line
223 .\"O or followed by a non-word constituent character.
224 .\"O Word-constituent characters are letters, digits, and the underscore.
225 マッチする部分が完全な単語を形成するときにのみ、その行を選択します。
226 次の条件を検査します。パターンにマッチする部分文字列は、行頭にあるか、
227 さもなければ、単語構成文字以外の文字の直後になければならない。
228 また、その部分文字列は、行末にあるか、さもなければ、単語構成文字以外の文字の
229 直前になければならない (訳注: ここで「完全な単語を形成する」というのは、
230 それが空白、改行、引用符、句読点などで前後を区切られた文字列だ
231 ということです。たとえば、文字列「A word with you」中の word という
232 部分文字列は完全な単語ですが、文字列「two words」中の部分文字列 word は
233 完全な単語を形成しません)。
234 単語構成文字とは、アルファベット、数字、アンダスコアです
235 (訳注: 実は漢字や仮名も単語構成文字として扱われます)。
236 .\"O This option has no effect if
237 .\"O .B \-x
238 .\"O is also specified.
239 このオプションは、
240 .B \-x
241 が同時に指定されたときには無効になります。
242 .TP
243 .BR \-x ", " \-\^\-line\-regexp
244 .\"O Select only those matches that exactly match the whole line.
245 パターンが行全体とぴったりマッチしたときにのみ、その行を選択します。
246 .\"O For a regular expression pattern, this is like parenthesizing the
247 .\"O pattern and then surrounding it with
248 .\"O .B ^
249 .\"O and
250 .\"O .BR $ .
251 正規表現でいうと、これはパターンを括弧で囲み、前後に
252 .B ^
253
254 .BR $
255 を付けるようなものです。
256 .TP
257 .B \-y
258 .\"O Obsolete synonym for
259 .\"O .BR \-i .
260 .BR \-i
261 と同じ意味を持つ旧式のオプションです。
262 .\"O .SS "General Output Control"
263 .SS "一般的な出力の制御"
264 .TP
265 .BR \-c ", " \-\^\-count
266 .\"O Suppress normal output; instead print a count of
267 .\"O matching lines for each input file.
268 .\"O With the
269 .\"O .BR \-v ", " \-\^\-invert\-match
270 .\"O option (see below), count non-matching lines.
271 通常の出力はせず、各入力ファイルについてマッチした行数を表示します。
272 .BR \-v ", " \-\^\-invert-match
273 オプション (上記参照) と共に指定した場合は、
274 マッチしなかった行数を表示します。
275 .TP
276 .BR \-\^\-color [ =\fIWHEN\fP "], " \-\^\-colour [ =\fIWHEN\fP ]
277 .\"O Surround the matched (non-empty) strings, matching lines, context lines,
278 .\"O file names, line numbers, byte offsets, and separators (for fields and
279 .\"O groups of context lines) with escape sequences to display them in color
280 .\"O on the terminal.
281 .\"O The colors are defined by the environment variable
282 .\"O .BR GREP_COLORS .
283 .\"O The deprecated environment variable
284 .\"O .B GREP_COLOR
285 .\"O is still supported, but its setting does not have priority.
286 .\"O .I WHEN
287 .\"O is
288 .\"O .BR never ", " always ", or " auto .
289 マッチした (空文字列ではない) 文字列、マッチする行、前後の文脈行、
290 ファイル名、行番号、バイトオフセット、(フィールドや、前後の文脈行を含む
291 グループ同士の) 区切り記号をエスケープ・シーケンスで囲み、ターミナル上に
292 色付きで表示します。
293 どの色を使うかは、環境変数
294 .B GREP_COLORS
295 で定義します。非推奨の環境変数
296 .B GREP_COLOR
297 も、これまでどおり使用できますが、その設定は優先されません。
298 .I WHEN
299
300 .BR never ", " always ", " auto
301 のいづれかです。
302 .TP
303 .BR \-L ", " \-\^\-files\-without\-match
304 .\"O Suppress normal output; instead print the name
305 .\"O of each input file from which no output would
306 .\"O normally have been printed.
307 .\"O The scanning will stop on the first match.
308 通常の出力はしません。その代わりに、
309 .BR grep
310 を普通に実行した際に、何の検索結果も表示しないような入力ファイルの名前を
311 列挙します (訳注: すなわち、\fB\-L\fR オプションを指定すると、
312 \fB\-v\fR オプションを同時に指定しない場合は、パターンにマッチする
313 文字列を含む行がまったく存在しないファイルの名前を列挙するということです)。
314 個々のファイルに対する走査は、最初のマッチで終了します。
315 .TP
316 .BR \-l ", " \-\^\-files\-with\-matches
317 .\"O Suppress normal output; instead print
318 .\"O the name of each input file from which output
319 .\"O would normally have been printed.
320 .\"O The scanning will stop on the first match.
321 通常の出力はしません。その代わりに、
322 .BR grep
323 を普通に実行した際に、何らかの検索結果を表示するような入力ファイルの名前を
324 列挙します (訳注: すなわち、\fB\-l\fR オプションを指定すると、
325 \fB\-v\fR オプションを同時に指定しない場合は、パターンにマッチする
326 文字列を含む行が存在するファイルの名前を列挙するということです)。
327 個々のファイルに対する走査は、最初のマッチで終了します。
328 .TP
329 .BI \-m " NUM" "\fR,\fP \-\^\-max\-count=" NUM
330 .\"O Stop reading a file after
331 .\"O .I NUM
332 .\"O matching lines.
333 .\"O If the input is standard input from a regular file,
334 .\"O and
335 .\"O .I NUM
336 .\"O matching lines are output,
337 .\"O .B grep
338 .\"O ensures that the standard input is positioned to just after the last
339 .\"O matching line before exiting, regardless of the presence of trailing
340 .\"O context lines.
341 .\"O This enables a calling process to resume a search.
342 .\"O When
343 .\"O .B grep
344 .\"O stops after
345 .\"O .I NUM
346 .\"O matching lines, it outputs any trailing context lines.
347 .\"O When the
348 .\"O .B \-c
349 .\"O or
350 .\"O .B \-\^\-count
351 .\"O option is also used,
352 .\"O .B grep
353 .\"O does not output a count greater than
354 .\"O .IR NUM .
355 .\"O When the
356 .\"O .B \-v
357 .\"O or
358 .\"O .B \-\^\-invert\-match
359 .\"O option is also used,
360 .\"O .B grep
361 .\"O stops after outputting
362 .\"O .I NUM
363 .\"O non-matching lines.
364 マッチした行数が
365 .I NUM
366 に達したら、ファイルの読み込みを中止します。
367 入力が通常ファイルから標準入力を介して行われている場合は、マッチした行を
368 .I NUM
369 行出力した時点で、
370 .B grep
371 は標準入力の読み出し位置を最後にマッチした行の直後に来るようにしてから、
372 終了します。続いて表示する文脈行がある場合でも、この動作は変わりません。
373 このことは、
374 .B grep
375 を呼び出すプロセスが、中止したところから検索を
376 再開することを可能にします。
377 .B grep
378 はマッチした行数が
379 .I NUM
380 に達してストップしたとき、それに続く文脈行があれば、それを出力します。
381 .B \-c
382
383 .B \-\^\-count
384 オプションを同時に使用した場合、
385 .B grep
386
387 .I NUM
388 よりも大きい数を出力しません。
389 .B \-v
390
391 .B \-\^\-invert\-match
392 を同時に使用した場合は、マッチしない行を
393 .I NUM
394 行出力したところで、
395 .B grep
396 はストップします。
397 .TP
398 .BR \-o ", " \-\^\-only\-matching
399 .\"O Print only the matched (non-empty) parts of a matching line,
400 .\"O with each such part on a separate output line.
401 マッチする行のマッチした部分だけを (それが空文字列でなければ) 表示します。
402 マッチした各文字列は、それぞれ別の行に書き出します。
403 .TP
404 .BR \-q ", " \-\^\-quiet ", " \-\^\-silent
405 .\"O Quiet; do not write anything to standard output.
406 .\"O Exit immediately with zero status if any match is found,
407 .\"O even if an error was detected.
408 .\"O Also see the
409 .\"O .B \-s
410 .\"O or
411 .\"O .B \-\^\-no\-messages
412 .\"O option.
413 沈黙モードです。標準出力に何も書き出しません。
414 マッチするものが 1 つでも見つかると、エラーを検出していた場合でも、
415 終了ステータス 0 で即座に終了します。
416 .B \-s
417
418 .B \-\^\-no\-messages
419 オプションも参照してください。
420 .TP
421 .BR \-s ", " \-\^\-no\-messages
422 .\"O Suppress error messages about nonexistent or unreadable files.
423 ファイルが存在しないことや読み込みめないことを示す
424 エラーメッセージを抑止します。
425 .\"O .SS "Output Line Prefix Control"
426 .SS "出力する行の前に付ける情報の制御"
427 .TP
428 .BR \-b ", " \-\^\-byte\-offset
429 .\"O Print the 0-based byte offset within the input file
430 .\"O before each line of output.
431 .\"O If
432 .\"O .B \-o
433 .\"O .RB ( \-\^\-only\-matching )
434 .\"O is specified,
435 .\"O print the offset of the matching part itself.
436 出力する各行の前に、その入力ファイル内での 0 から始まる
437 バイト単位のオフセットを表示します。
438 .B \-o
439 .RB ( \-\^\-only\-matching )
440 も指定されているときは、マッチする部分そのもののオフセットを示します。
441 .TP
442 .BR \-H ", " \-\^\-with\-filename
443 .\"O Print the file name for each match.
444 .\"O This is the default when there is more than one file to search.
445 各々のマッチに対してそのファイル名を表示します。
446 検索するファイルが 2 個以上の場合は、これがデフォルトの動作です。
447 .TP
448 .BR \-h ", " \-\^\-no\-filename
449 .\"O Suppress the prefixing of file names on output.
450 .\"O This is the default when there is only one file
451 .\"O (or only standard input) to search.
452 出力する行の前にファイル名を付けないようにします。
453 検索するファイルが 1 つしかない (あるいは、標準入力だけだった) 場合は、
454 これがデフォルトの動作です。
455 .TP
456 .BI \-\^\-label= LABEL
457 .\"O Display input actually coming from standard input as input coming from file
458 .\"O .IR LABEL.
459 .\"O This is especially useful when implementing tools like
460 .\"O .BR zgrep ,
461 .\"O e.g.,
462 .\"O .BR "gzip -cd foo.gz | grep --label=foo -H something" .
463 .\"O See also the
464 .\"O .B \-H
465 .\"O option.
466 実際には標準入力から来た入力を
467 .IR LABEL
468 というファイルから来たもののように見せかけます。
469 これは
470 .BR zgrep
471 のようなツールを自分で作成する際にとりわけ便利です。たとえば、
472 .BR "gzip -cd foo.gz | grep --label=foo -H something"
473 といった具合です。
474 .B \-H
475 オプションも参照してください。
476 .TP
477 .BR \-n ", " \-\^\-line\-number
478 .\"O Prefix each line of output with the 1-based line number
479 .\"O within its input file.
480 各出力行の前に、その入力ファイル内での 1 から始まる行番号を表示します。
481 .TP
482 .BR \-T ", " \-\^\-initial\-tab
483 .\"O Make sure that the first character of actual line content lies on a
484 .\"O tab stop, so that the alignment of tabs looks normal.
485 .\"O This is useful with options that prefix their output to the actual content:
486 .\"O .BR \-H , \-n ,
487 .\"O and
488 .\"O .BR \-b .
489 .\"O In order to improve the probability that lines
490 .\"O from a single file will all start at the same column,
491 .\"O this also causes the line number and byte offset (if present)
492 .\"O to be printed in a minimum size field width.
493 行の実際の内容をなす最初の文字が、必ずタブ・ストップの位置に
494 来るようにします。その結果、タブがきちんと揃って見えるようになります。
495 このオプションは
496 .BR \-H , \-n , \-b
497 といった、実際の内容の前に情報を付加するオプションを使うときに
498 役に立ちます。
499 また、このオプションは、
500 1 つのファイルから抜き出した行の先頭ができるだけ揃うように、
501 行番号やバイトオフセットがある場合は、そのフィールド幅を
502 必要最小のサイズにして表示します。
503 .TP
504 .BR \-u ", " \-\^\-unix\-byte\-offsets
505 .\"O Report Unix-style byte offsets.
506 .\"O This switch causes
507 .\"O .B grep
508 .\"O to report byte offsets as if the file were a Unix-style text file,
509 .\"O i.e., with CR characters stripped off.
510 .\"O This will produce results identical to running
511 .\"O .B grep
512 .\"O on a Unix machine.
513 .\"O This option has no effect unless
514 .\"O .B \-b
515 .\"O option is also used;
516 .\"O it has no effect on platforms other than \s-1MS-DOS\s0 and \s-1MS\s0-Windows.
517 Unix 形式のバイトオフセットを報告します。
518 このスイッチを使うと、
519 .B grep
520 は、検索対象のファイルが Unix 形式のテキストファイルであるかのように、
521 バイトオフセットを報告します。すなわち、CR 文字を切り捨てるのです。
522 そのため、表示される結果は、Unix マシンで
523 .B grep
524 を実行したときと同じものになります。
525 このオプションは、
526 .B \-b
527 オプションを同時に使用しないかぎり、効果がありません。
528 また、このオプションは、\s-1MS-DOS\s0 と \s-1MS\s0-Windows 以外の
529 プラットホームでは、何の効果もありません。
530 .TP
531 .BR \-Z ", " \-\^\-null
532 .\"O Output a zero byte (the \s-1ASCII\s0
533 .\"O .B NUL
534 .\"O character) instead of the character that normally follows a file name.
535 .\"O For example,
536 .\"O .B "grep \-lZ"
537 .\"O outputs a zero byte after each file name instead of the usual newline.
538 .\"O This option makes the output unambiguous, even in the presence of file
539 .\"O names containing unusual characters like newlines.
540 .\"O This option can be used with commands like
541 .\"O .BR "find \-print0" ,
542 .\"O .BR "perl \-0" ,
543 .\"O .BR "sort \-z" ,
544 .\"O and
545 .\"O .B "xargs \-0"
546 .\"O to process arbitrary file names,
547 .\"O even those that contain newline characters.
548 ファイル名に続いて通常出力される文字の代わりに、
549 値が 0 の 1 バイト (\s-1ASCII\s0
550 .B NUL
551 文字) を出力します。
552 たとえば、
553 .B "grep \-lZ"
554 は、いつもの改行 (newline) ではなく、値が 0 の 1 バイトを各ファイル名の後ろに
555 出力するのです。
556 このオプションは、改行のような変わった文字を含むファイル名があるときでも、
557 出力の曖昧さをなくしてくれます。
558 このオプションを
559 .BR "find \-print0" ,
560 .BR "perl \-0" ,
561 .BR "sort \-z" ,
562 .B "xargs \-0"
563 などのコマンドと組み合わせて使うと、行儀の悪いファイル名も
564 処理することができます。
565 ファイル名が改行文字を含んでいても処理できるのです。
566 .\"O .SS "Context Line Control"
567 .SS "前後の文脈行の制御"
568 .TP
569 .BI \-A " NUM" "\fR,\fP \-\^\-after\-context=" NUM
570 .\"O Print
571 .\"O .I NUM
572 .\"O lines of trailing context after matching lines.
573 .\"O Places a line containing a group separator
574 .\"O .RB ( \-\^\- )
575 .\"O between contiguous groups of matches.
576 .\"O With the
577 .\"O .B \-o
578 .\"O or
579 .\"O .B \-\^\-only\-matching
580 .\"O option, this has no effect and a warning is given.
581 .I NUM
582 で指定した行数だけ、パターンにマッチした行の後に続く文脈も表示します。
583 マッチした行を含むグループ同士の間には、グループを区切る印
584 .RB ( \-\^\- )
585 からなる行を置きます。
586 .B \-o
587
588 .B \-\^\-only\-matching
589 と同時に使うと、このオプションは効果がなく、警告メッセージを出します。
590 .TP
591 .BI \-B " NUM" "\fR,\fP \-\^\-before\-context=" NUM
592 .\"O Print
593 .\"O .I NUM
594 .\"O lines of leading context before matching lines.
595 .\"O Places a line containing a group separator
596 .\"O .RB ( \-\^\- )
597 .\"O between contiguous groups of matches.
598 .\"O With the
599 .\"O .B \-o
600 .\"O or
601 .\"O .B \-\^\-only\-matching
602 .\"O option, this has no effect and a warning is given.
603 .I NUM
604 で指定した行数だけ、パターンにマッチした行に先行する文脈も表示します。
605 マッチした行を含むグループ同士の間には、グループを区切る印
606 .RB ( \-\^\- )
607 からなる行を置きます。
608 .B \-o
609
610 .B \-\^\-only\-matching
611 と同時に使うと、このオプションは効果がなく、警告メッセージを出します。
612 .TP
613 .BI \-C " NUM" "\fR,\fP \-" NUM "\fR,\fP \-\^\-context=" NUM
614 .\"O Print
615 .\"O .I NUM
616 .\"O lines of output context.
617 .\"O Places a line containing a group separator
618 .\"O .RB ( \-\^\- )
619 .\"O between contiguous groups of matches.
620 .\"O With the
621 .\"O .B \-o
622 .\"O or
623 .\"O .B \-\^\-only\-matching
624 .\"O option, this has no effect and a warning is given.
625 .I NUM
626 で指定した行数だけ、パターンにマッチした行の前後の文脈も表示します。
627 マッチした行を含むグループ同士の間には、グループを区切る印
628 .RB ( \-\^\- )
629 からなる行を置きます。
630 .B \-o
631
632 .B \-\^\-only\-matching
633 と同時に使うと、このオプションは効果がなく、警告メッセージを出します。
634 .\"O .SS "File and Directory Selection"
635 .SS "ファイルやディレクトリの選択"
636 .TP
637 .BR \-a ", " \-\^\-text
638 .\"O Process a binary file as if it were text; this is equivalent to the
639 .\"O .B \-\^\-binary\-files=text
640 .\"O option.
641 バイナリファイルをテキストファイルであるかのように処理します。
642 これは
643 .B \-\^\-binary-files=text
644 オプションと等価です。
645 .TP
646 .BI \-\^\-binary\-files= TYPE
647 .\"O If a file's data or metadata
648 .\"O indicate that the file contains binary data,
649 .\"O assume that the file is of type
650 .\"O .IR TYPE .
651 ファイルのデータやメタデータが、
652 ファイルにバイナリデータが含まれていることを示す場合に、
653 ファイルのタイプを
654 .IR TYPE
655 だと見なします。
656 .\"O Non-text bytes indicate binary data; these are either output bytes that are
657 .\"O improperly encoded for the current locale, or null input bytes when the
658 .\"O .B \-z
659 .\"O option is not given.
660 .\"O .IP
661 テキストではないバイトが見つかれば、バイナリデータです。
662 テキストではないバイトが、
663 現在使用しているロケールに不適切にエンコードして出力されたバイトや、
664 .B \-z
665 オプションが指定されていないときの入力中のヌルバイトだということもあります。
666 .IP
667 .\"O By default,
668 .\"O .I TYPE
669 .\"O is
670 .\"O .BR binary ,
671 .\"O and when
672 .\"O .B grep
673 .\"O discovers that a file is binary it suppresses any further output, and
674 .\"O instead outputs either a one-line message saying that a binary file
675 .\"O matches, or no message if there is no match.
676 .\"O .IP
677 デフォルトでは
678 .I TYPE
679
680 .BR binary
681 であり、
682 .B grep
683 はファイルがバイナリだとわかると、
684 その先の出力を抑制します。そのかわりにバイナリファイルにマッチしたという
685 1 行のメッセージを表示します。マッチする部分がない場合には何も表示しません。
686 .IP
687 .\"O If
688 .\"O .I TYPE
689 .\"O is
690 .\"O .BR without-match ,
691 .\"O when
692 .\"O .B grep
693 .\"O discovers that a file is binary it assumes that the rest of the file
694 .\"O does not match; this is equivalent to the
695 .\"O .B \-I
696 .\"O option.
697 .\"O .IP
698 .I TYPE
699
700 .BR without-match
701 の場合、
702 .B grep
703 はファイルがバイナリだとわかると、残りはマッチしないものと仮定します。
704 これは
705 .B \-I
706 オプションと等価です。
707 .IP
708 .\"O If
709 .\"O .I TYPE
710 .\"O is
711 .\"O .BR text ,
712 .\"O .B grep
713 .\"O processes a binary file as if it were text; this is equivalent to the
714 .\"O .B \-a
715 .\"O option.
716 .\"O .IP
717 .I TYPE
718
719 .BR text
720 の場合、
721 .B grep
722 はバイナリファイルをテキストであるかのように扱います。
723 これは
724 .B \-a
725 オプションと等価です。
726 .IP
727 .\"O When
728 .\"O .I type
729 .\"O is
730 .\"O .BR binary ,
731 .\"O .B grep
732 .\"O may treat non-text bytes as line terminators even without the
733 .\"O .B \-z
734 .\"O option.  This means choosing
735 .\"O .B binary
736 .\"O versus
737 .\"O .B text
738 .\"O can affect whether a pattern matches a file.  For
739 .\"O example, when
740 .\"O .I type
741 .\"O is
742 .\"O .B binary
743 .\"O the pattern
744 .\"O .B q$ might
745 .\"O match
746 .\"O .B q
747 .\"O immediately followed by a null byte, even though this
748 .\"O is not matched when
749 .\"O .I type
750 .\"O is
751 .\"O .BR text .
752 .I type
753
754 .BR binary
755 の場合、
756 .B grep
757
758 .B \-z
759 がなくてもテキスト以外の文字を行の区切りとして扱う場合があります。
760 これは、
761 .B binary
762 を選ぶか
763 .B text
764 を選ぶかによって、
765 パターンがファイルにマッチするかどうかに影響があることを意味します。
766 たとえば、
767 .I type
768
769 .B binary
770 の場合は
771 .B q$
772 というパターンが
773 .B q
774 の直後に NULL 文字が続く箇所にマッチする可能性があるのに対し、
775 .I type
776
777 .BR text
778 の場合にはマッチしません。
779 .\"O Conversely, when
780 .\"O .I type
781 .\"O is
782 .\"O .B binary
783 .\"O the pattern
784 .\"O .B .\&
785 .\"O (period) might not match a null byte.
786 .\"O .IP
787 逆に、
788 .I type
789
790 .B binary
791 の場合、
792 .B .\&
793 (period) というパターンは NULL 文字にはマッチしないかもしれません。
794 .IP
795 .\"O .I Warning:
796 .\"O The
797 .\"O .B \-a
798 .\"O option might output binary garbage,
799 .\"O which can have nasty side effects if the output is a terminal and if the
800 .\"O terminal driver interprets some of it as commands.
801 .I 警告:
802 .B \-a
803 オプションはバイナリのゴミを出力するかもしれません。
804 出力先が端末であり、しかも
805 端末ドライバがゴミの一部をコマンドだと解釈する場合には、
806 このゴミが厄介な副作用を起こす可能性があります。
807 .\"O On the other hand, when reading files whose text encodings are
808 .\"O unknown, it can be helpful to use
809 .\"O .B \-a
810 .\"O or to set
811 .\"O .B LC_ALL='C'
812 .\"O in the environment, in order to find more matches even if the matches
813 .\"O are unsafe for direct display.
814 一方、テキストのエンコーディングが不明なファイルを読み込むとき、
815 マッチした結果をそのまま表示するのが安全でなくても、
816 より多くのマッチを探すために、
817 .B \-a
818 を指定するか、環境変数で
819 .B LC_ALL='C'
820 を指定するのが役に立つ場合があります。
821 .TP
822 .BI \-D " ACTION" "\fR,\fP \-\^\-devices=" ACTION
823 .\"O If an input file is a device, FIFO or socket, use
824 .\"O .I ACTION
825 .\"O to process it.
826 .\"O By default,
827 .\"O .I ACTION
828 .\"O is
829 .\"O .BR read ,
830 .\"O which means that devices are read just as if they were ordinary files.
831 .\"O If
832 .\"O .I ACTION
833 .\"O is
834 .\"O .BR skip ,
835 .\"O devices are silently skipped.
836 入力ファイルがデバイス、FIFO、ソケットのいづれかである場合に、
837 .I ACTION
838 を使ってその処理を行います。
839 デフォルトの
840 .I ACTION
841
842 .BR read
843 です。すなわち、デバイスなどを、それが普通のファイルであるかのように、
844 読み込みます。
845 .I ACTION
846
847 .BR skip
848 ならば、デバイスなどを黙ってスキップします。
849 .TP
850 .BI \-d " ACTION" "\fR,\fP \-\^\-directories=" ACTION
851 .\"O If an input file is a directory, use
852 .\"O .I ACTION
853 .\"O to process it.
854 .\"O By default,
855 .\"O .I ACTION
856 .\"O is
857 .\"O .BR read ,
858 .\"O i.e., read directories just as if they were ordinary files.
859 .\"O If
860 .\"O .I ACTION
861 .\"O is
862 .\"O .BR skip ,
863 .\"O silently skip directories.
864 .\"O If
865 .\"O .I ACTION
866 .\"O is
867 .\"O .BR recurse ,
868 .\"O read all files under each directory, recursively,
869 .\"O following symbolic links only if they are on the command line.
870 .\"O This is equivalent to the
871 .\"O .B \-r
872 .\"O option.
873 入力ファイルがディレクトリの場合に、
874 .I ACTION
875 を使ってその処理を行います。デフォルトの
876 .I ACTION
877
878 .BR read
879 です。すなわち、ディレクトリを、それが普通のファイルであるかのように、
880 読み込みます。
881 .I ACTION
882
883 .BR skip
884 ならば、ディレクトリを黙ってスキップします。
885 .I ACTION
886
887 .BR recurse
888 なら、
889 .B
890 grep
891 は各ディレクトリの下にあるすべてのファイルを再帰的に読み込みます。
892 ただし、シンボリックリンクはコマンドラインで指定されたときにのみたどります。
893 これは
894 .B \-r
895 オプションと等価です。
896 .TP
897 .BI \-\^\-exclude= GLOB
898 .\"O Skip any command-line file with a name suffix that matches the pattern
899 .\"O .IR GLOB ,
900 .\"O using wildcard matching; a name suffix is either the whole
901 .\"O name, or any suffix starting after a
902 .\"O .B /
903 .\"O and before a +non-\fB/\fP.
904 コマンドラインで指定されているファイルについては、
905 その名前の尾部が、
906 ワイルドカードによるマッチングでパターン
907 .IR GLOB
908 にマッチするファイルをスキップします。
909 ここで言う「名前の尾部」とは、
910 ファイル名の全体か、
911 .B /
912 の直後に始まり
913 .B /
914 以外の文字で終るファイル名の最後の部分のことです。
915 .\"O When searching recursively, skip any subfile whose base name matches
916 .\"O .IR GLOB ;
917 .\"O the base name is the part after the last
918 .\"O .BR / .
919 また、ディレクトリを再帰検索しているときに出会うファイルについては、
920 ベースネームが
921 .IR GLOB
922 にマッチするファイルをスキップします。
923 ベースネームとは最後の
924 .BR /
925 より後の部分です。
926 .\"O A pattern can use.\"O .\"O .BR * ,
927 .\"O .BR ? ,
928 .\"O and
929 .\"O .BR [ ... ]
930 .\"O as wildcards, and
931 .\"O .B \e
932 .\"O to quote a wildcard or backslash character literally.
933 パターンには、
934 .BR * ,
935 .BR ? ,
936 .BR [ ... ]
937 がワイルドカードとして使えます。
938 .B \e
939 を文字の前に置けば、
940 ワイルドカード文字やバックスラッシュ文字を本来の意味で使用できます。
941 .TP
942 .BI \-\^\-exclude-from= FILE
943 .\"O Skip files whose base name matches any of the file-name globs read from
944 .\"O .I FILE
945 .\"O (using wildcard matching as described under
946 .\"O .BR \-\^\-exclude ).
947 ファイル
948 .I FILE
949 を読み込み、そこに書かれているファイル名 (ワイルドカード可) のどれかに
950 ベースネームがマッチするファイルをスキップします
951 .RB ( \-\^\-exclude
952 の項で説明したワイルドカードのマッチングを使用します)。
953 .TP
954 .BI \-\^\-exclude-dir= GLOB
955 .\"O Skip any command-line directory with a name suffix that matches the
956 .\"O pattern
957 .\"O .IR GLOB .
958 コマンドラインで指定されているディレクトリのうち、
959 名前の尾部がパターン
960 .IR GLOB
961 にマッチするディレクトリをスキップします。
962 .\"O When searching recursively, skip any subdirectory
963 .\"O whose base name matches
964 .\"O .IR GLOB .
965 また、ディレクトリを再帰検索しているときに出会うサブディレクトリについては、
966 ベースネームが
967 .IR GLOB
968 にマッチするサブディレクトリをスキップします。
969 .\"O Ignore any redundant trailing slashes in
970 .\"O .IR GLOB .
971 .IR GLOB
972 末尾の余分なスラッシュは無視されます。
973 .TP
974 .BR \-I
975 .\"O Process a binary file as if it did not contain matching data; this is
976 .\"O equivalent to the
977 .\"O .B \-\^\-binary\-files=without-match
978 .\"O option.
979 バイナリファイルをマッチするデータを含んでいないものとして
980 処理します。これは
981 .B \-\^\-binary\-files=without-match
982 オプションと等価です。
983 .TP
984 .BI \-\^\-include= GLOB
985 .\"O Search only files whose base name matches
986 .\"O .I GLOB
987 .\"O (using wildcard matching as described under
988 .\"O .BR \-\^\-exclude ).
989 ベースネームが
990 .I GLOB
991 にマッチするファイルのみを検索します
992 .RB ( \-\^\-exclude
993 の項で説明したワイルドカードのマッチングを使用します)。
994 .TP
995 .BR \-r ", " \-\^\-recursive
996 .\"O Read all files under each directory, recursively,
997 .\"O following symbolic links only if they are on the command line.
998 各ディレクトリの下にあるすべてのファイルを再帰的に読み込みます。
999 ただし、シンボリックリンクはコマンドラインで指定されたときにのみたどります。
1000 .\"O Note that if no file operand is given, grep searches the working directory.
1001 検索対象のファイルが指定されなかった場合には
1002 grep は現在のディレクトリを探すことに注意してください。
1003 .\"O This is equivalent to the
1004 .\"O .B "\-d recurse"
1005 .\"O option.
1006 これは
1007 .B "\-d recurse"
1008 オプションと等価です。
1009 .TP
1010 .BR \-R ", " \-\^\-dereference\-recursive
1011 .\"O Read all files under each directory, recursively.
1012 .\"O Follow all symbolic links, unlike
1013 .\"O .BR \-r .
1014 各ディレクトリの下にあるすべてのファイルを再帰的に読み込みます。
1015 .BR \-r
1016 と異なり、すべてのシンボリックリンクを追跡します。
1017 .\"O .SS "Other Options"
1018 .SS "その他のオプション"
1019 .TP
1020 .BR \-\^\-line\-buffered
1021 .\"O Use line buffering on output.
1022 .\"O This can cause a performance penalty.
1023 行ごとに出力を行います。
1024 実行速度が落ちるかもしれません。
1025 .TP
1026 .BR \-U ", " \-\^\-binary
1027 .\"O Treat the file(s) as binary.
1028 ファイルをバイナリとして扱います。
1029 .\"O By default, under \s-1MS-DOS\s0 and \s-1MS\s0-Windows,
1030 .\"O .BR grep
1031 .\"O guesses the file type by looking at the contents of the first 32KB
1032 .\"O read from the file.
1033 MS-DOS や MS-Windows の環境下で、
1034 .BR grep
1035 はデフォルトでは、
1036 ファイルがテキストかバイナリかを
1037 .B \-\^\-binary\-files
1038 オプションで記述された方法で推測します。
1039 .\"O If
1040 .\"O .BR grep
1041 .\"O decides the file is a text file, it strips the CR characters from the
1042 .\"O original file contents (to make regular expressions with
1043 .\"O .B ^
1044 .\"O and
1045 .\"O .B $
1046 .\"O work correctly).
1047 .BR grep
1048 はファイルをテキストファイルと判断した場合、オリジナルのファイル内容から
1049 .RB ( ^
1050
1051 .B $
1052 を使った正規表現が正しく動作するように)
1053 CR 文字を取り除きます。
1054 .\"O Specifying
1055 .\"O .B \-U
1056 .\"O overrules this guesswork, causing all files to be read and passed to the
1057 .\"O matching mechanism verbatim; if the file is a text file with CR/LF
1058 .\"O pairs at the end of each line, this will cause some regular
1059 .\"O expressions to fail.
1060 .B \-U
1061 を指定すると、この推測を抑制し、すべてのファイルを読み取って、
1062 そのまま手を加えずにマッチ処理へ渡すのです。もしファイルが
1063 各行の末尾に CR/LF の組み合わせを持つテキストファイルなら、
1064 このオプションのせいで正規表現がうまく働かないことがあるかもしれません。
1065 .\"O This option has no effect on platforms
1066 .\"O other than \s-1MS-DOS\s0 and \s-1MS\s0-Windows.
1067 このオプションは MS-DOS や MS-Windows 以外のプラットフォームでは
1068 効果がありません。
1069 .TP
1070 .BR \-z ", " \-\^\-null\-data
1071 .\"O Treat input and output data as sequences of lines, each terminated by
1072 .\"O a zero byte (the ASCII NUL character) instead of a newline.
1073 入力と出力のデータを、
1074 改行のかわりに、
1075 値が 0 のバイト (ASCII NULL 文字) で区切られた一連の行として扱います。
1076 .\"O Like the
1077 .\"O .B \-Z
1078 .\"O or
1079 .\"O .B \-\^\-null
1080 .\"O option, this option can be used with commands like
1081 .\"O .B sort -z
1082 .\"O to process arbitrary file names.
1083 .\"O .
1084 .B \-Z
1085
1086 .B \-\^\-null
1087 と同様、このオプションは
1088 .B sort -z
1089 などのコマンドと組み合わせて、
1090 行儀の悪いファイル名の処理に使用することができます。
1091 .\"O .SH "REGULAR EXPRESSIONS"
1092 .SH "正規表現"
1093 .\"O A regular expression is a pattern that describes a set of strings.
1094 .\"O Regular expressions are constructed analogously to arithmetic
1095 .\"O expressions, by using various operators to combine smaller expressions.
1096 .\"O .PP
1097 正規表現とは、一群の文字列を一まとめにして表現するパターンのことです。
1098 正規表現の構成方法は、数式によく似ています。すなわち、さまざまな演算子を
1099 使い、小さな表現を組み合わせて構成するのです。
1100 .PP
1101 .\"O .B grep
1102 .\"O understands three different versions of regular expression syntax:
1103 .\"O \*(lqbasic\*(rq (BRE), \*(lqextended\*(rq (ERE) and \*(lqperl\*(rq (PCRE).
1104 .\"O In
1105 .\"O .RB "\s-1GNU\s0\ " grep ,
1106 .\"O there is no difference in available functionality between basic and
1107 .\"O extended syntaxes.
1108 .\"O In other implementations, basic regular expressions are less powerful.
1109 .\"O The following description applies to extended regular expressions;
1110 .\"O differences for basic regular expressions are summarized afterwards.
1111 .\"O Perl-compatible regular expressions give additional functionality, and are
1112 .\"O documented in pcresyntax(3) and pcrepattern(3), but only work if
1113 .\"O PCRE is available in the system.
1114 .\"O .PP
1115 .B grep
1116 は、「基本」正規表現 (BRE)、「拡張」正規表現 (ERE)、「Perl の」正規表現
1117 (PCRE) という 3 種類の正規表現文法を扱うことができます。
1118 .RB "\s-1GNU\s0\ " grep
1119 では、「基本」と「拡張」の文法の間で、利用できる機能に違いはありません。
1120 他の実装では、基本正規表現は拡張正規表現ほど強力ではないものです。
1121 ここでは、拡張正規表現について説明し、
1122 基本正規表現との相違については、後で簡単にまとめることにします。
1123 なお、Perl 互換の正規表現にはより多くの機能があり、
1124 pcresyntax(3) や pcrepattern(3) で詳細に解説されていますが、
1125 PCRE が用意されているシステムでしか利用できません。
1126 .PP
1127 .\"O The fundamental building blocks are the regular expressions
1128 .\"O that match a single character.
1129 .\"O Most characters, including all letters and digits,
1130 .\"O are regular expressions that match themselves.
1131 .\"O Any meta-character with special meaning
1132 .\"O may be quoted by preceding it with a backslash.
1133 .\"O .PP
1134 正規表現を構成する基本単位は、1 文字にマッチする正規表現です。
1135 アルファベットや数字を含むほとんどの文字が、自分自身にマッチする正規表現です。
1136 また、特殊な意味を持つメタ文字も、その文字の前にバックスラッシュ
1137 を付けると、その本来の文字にマッチするようになります。
1138 .PP
1139 .\"O The period
1140 .\"O .B .\&
1141 .\"O matches any single character.
1142 ピリオド
1143 .B .\&
1144 は、任意の 1 文字にマッチします。
1145 .\"O .SS "Character Classes and Bracket Expressions"
1146 .SS "文字クラスと角括弧式 (ブラケット式)"
1147 .\"O A
1148 .\"O .I "bracket expression"
1149 .\"O is a list of characters enclosed by
1150 .\"O .B [
1151 .\"O and
1152 .\"O .BR ] .
1153 .\"O It matches any single
1154 .\"O character in that list; if the first character of the list
1155 .\"O is the caret
1156 .\"O .B ^
1157 .\"O then it matches any character
1158 .\"O .I not
1159 .\"O in the list.
1160 .\"O For example, the regular expression
1161 .\"O .B [0123456789]
1162 .\"O matches any single digit.
1163 .\"O .PP
1164 .I "角括弧式"
1165 とは、
1166 .B [
1167
1168 .BR ]
1169 で囲まれた文字のリストのことです。
1170 .I "角括弧式"
1171 は、リスト中の任意の 1 文字にマッチします。
1172 また、リストの最初の文字がキャレット
1173 .B ^
1174 の場合は、リスト中の文字以外の任意の 1 文字にマッチします。
1175 たとえば、正規表現
1176 .B [0123456789]
1177 は任意の数字 1 個にマッチするわけです。
1178 .PP
1179 .\"O Within a bracket expression, a
1180 .\"O .I "range expression"
1181 .\"O consists of two characters separated by a hyphen.
1182 .\"O It matches any single character that sorts between the two characters,
1183 .\"O inclusive, using the locale's collating sequence and character set.
1184 .\"O For example, in the default C locale,
1185 .\"O .B [a\-d]
1186 .\"O is equivalent to
1187 .\"O .BR [abcd] .
1188 .\"O Many locales sort characters in dictionary order, and in these locales
1189 .\"O .B [a\-d]
1190 .\"O is typically not equivalent to
1191 .\"O .BR [abcd] ;
1192 .\"O it might be equivalent to
1193 .\"O .BR [aBbCcDd] ,
1194 .\"O for example.
1195 .\"O To obtain the traditional interpretation of bracket expressions,
1196 .\"O you can use the C locale by setting the
1197 .\"O .B LC_ALL
1198 .\"O environment variable to the value
1199 .\"O .BR C .
1200 .\"O .PP
1201 角括弧式の内側に
1202 .I "範囲式"
1203 を置くことができますが、これはハイフンで区切られた 2 つの文字から
1204 なっています。範囲式は、現在使用中のロケールにおける照合順序と
1205 文字集合を使ったときに、その 2 文字の間に並ぶ、その 2 文字を含む
1206 任意の 1 文字にマッチします。
1207 たとえば、デフォルトの C ロケールでは、
1208 .B [a\-d]
1209
1210 .BR [abcd]
1211 と等価です。
1212 多くのロケールでは文字を辞書式の順序で並べていますが、そうしたロケールで
1213 .B [a\-d]
1214
1215 .BR [abcd]
1216 と等価でないこともよくあります。
1217 たとえば、
1218 .BR [aBbCcDd]
1219 と等価かもしれないのです。
1220 角括弧式を伝統的な意味に解釈させたいなら、
1221 環境変数
1222 .B LC_ALL
1223 の値を
1224 .BR C
1225 に設定して、C ロケールを使用するとよいでしょう。
1226 .PP
1227 .\"O Finally, certain named classes of characters are predefined within
1228 .\"O bracket expressions, as follows.
1229 .\"O Their names are self explanatory, and they are
1230 .\"O .BR [:alnum:] ,
1231 .\"O .BR [:alpha:] ,
1232 .\"O .BR [:cntrl:] ,
1233 .\"O .BR [:digit:] ,
1234 .\"O .BR [:graph:] ,
1235 .\"O .BR [:lower:] ,
1236 .\"O .BR [:print:] ,
1237 .\"O .BR [:punct:] ,
1238 .\"O .BR [:space:] ,
1239 .\"O .BR [:upper:] ,
1240 .\"O and
1241 .\"O .BR [:xdigit:].
1242 .\"O For example,
1243 .\"O .B [[:alnum:]]
1244 .\"O means the character class of numbers and
1245 .\"O letters in the current locale. In the C locale and \s-1ASCII\s0
1246 .\"O character set encoding, this is the same as
1247 .\"O .BR [0\-9A\-Za\-z] .
1248 .\"O (Note that the brackets in these class names are part of the symbolic
1249 .\"O names, and must be included in addition to the brackets delimiting
1250 .\"O the bracket expression.)
1251 .\"O Most meta-characters lose their special meaning inside bracket expressions.
1252 .\"O To include a literal
1253 .\"O .B ]
1254 .\"O place it first in the list.
1255 .\"O Similarly, to include a literal
1256 .\"O .B ^
1257 .\"O place it anywhere but first.
1258 .\"O Finally, to include a literal
1259 .\"O .B \-
1260 .\"O place it last.
1261 最後に、角括弧式内で使えるように、特定の名前を持つ文字クラスが
1262 あらかじめ定義されています。
1263 名前が内容を示しており、それは次のようなものです。
1264 .BR [:alnum:] ,
1265 .BR [:alpha:] ,
1266 .BR [:cntrl:] ,
1267 .BR [:digit:] ,
1268 .BR [:graph:] ,
1269 .BR [:lower:] ,
1270 .BR [:print:] ,
1271 .BR [:punct:] ,
1272 .BR [:space:] ,
1273 .BR [:upper:] ,
1274 .BR [:xdigit:]。
1275 たとえば、
1276 .B [[:alnum:]]
1277
1278 現在のロケールの文字クラスで数字と文字を意味します。
1279 C ロケールや \s-1ASCII\s0 文字集合のエンコーディングの場合、
1280 これは
1281 .BR [0\-9A\-Za\-z]
1282 と同じです。
1283 (こうしたクラス名に使用されている角括弧は、シンボル名の一部なので、
1284 角括弧式の前後に付く角括弧とは別に指定する必要があることに
1285 注意してください。)
1286 角括弧式の内側では、ほとんどのメタ文字がその特別な意味を
1287 持たなくなります。
1288 .B ]
1289 という記号そのものを角括弧式に含めるには、
1290 それをリストの先頭に置いてください。
1291 同様に、
1292 .B ^
1293 という記号そのものを含めるには、
1294 それを先頭以外のどこかに置けばよいでしょう。
1295 最後に、
1296 .B \-
1297 そのものを含めるには、
1298 それをリストの最後に置きます。
1299 .\"O .SS Anchoring
1300 .SS "行頭と行末 (アンカリング)"
1301 .\"O The caret
1302 .\"O .B ^
1303 .\"O and the dollar sign
1304 .\"O .B $
1305 .\"O are meta-characters that respectively match the empty string at the
1306 .\"O beginning and end of a line.
1307 キャレット
1308 .B ^
1309
1310 ドル記号
1311 .B $
1312 は、それぞれ行頭と行末の空文字列にマッチするメタ文字です。
1313 .\"O .SS "The Backslash Character and Special Expressions"
1314 .SS "バックスラッシュ付きの特別な表現"
1315 .\"O The symbols
1316 .\"O .B \e<
1317 .\"O and
1318 .\"O .B \e>
1319 .\"O respectively match the empty string at the beginning and end of a word.
1320 .\"O The symbol
1321 .\"O .B \eb
1322 .\"O matches the empty string at the edge of a word,
1323 .\"O and
1324 .\"O .B \eB
1325 .\"O matches the empty string provided it's
1326 .\"O .I not
1327 .\"O at the edge of a word.
1328 .\"O The symbol
1329 .\"O .B \ew
1330 .\"O is a synonym for
1331 .\"O .B [_[:alnum:]]
1332 .\"O and
1333 .\"O .B \eW
1334 .\"O is a synonym for
1335 .\"O .BR [^_[:alnum:]] .
1336 シンボル
1337 .B \e<
1338 とシンボル
1339 .B \e>
1340 は、それぞれ単語の先頭と末尾の空文字列にマッチするメタ文字です。
1341 シンボル
1342 .B \eb
1343 は単語の端の空文字列にマッチします。
1344 シンボル
1345 .B \eB
1346 は単語の端
1347 .I 以外
1348 の空文字列にマッチします。
1349 シンボル
1350 .B \ew
1351
1352 .B [_[:alnum:]]
1353 と同じ意味で、
1354 シンボル
1355 .B \eW
1356
1357 .B [^_[:alnum:]]
1358 と同じ意味です。
1359 .\"O .SS Repetition
1360 .SS "繰り返し"
1361 .\"O A regular expression may be followed by one of several repetition operators:
1362 正規表現の後には、繰り返し演算子のどれかが続くことがあります。
1363 .PD 0
1364 .TP
1365 .B ?
1366 .\"O The preceding item is optional and matched at most once.
1367 直前の項目があってもなくてもよく、マッチするとしても 1 回だけということ。
1368 .TP
1369 .B *
1370 .\"O The preceding item will be matched zero or more times.
1371 直前の項目が 0 回以上マッチするということ。
1372 .TP
1373 .B +
1374 .\"O The preceding item will be matched one or more times.
1375 直前の項目が 1 回以上マッチするということ。
1376 .TP
1377 .BI { n }
1378 .\"O The preceding item is matched exactly
1379 .\"O .I n
1380 .\"O times.
1381 直前の項目がちょうど
1382 .I n
1383 回マッチするということ。
1384 .TP
1385 .BI { n ,}
1386 .\"O The preceding item is matched
1387 .\"O .I n
1388 .\"O or more times.
1389 直前の項目が
1390 .I n
1391 回以上マッチするということ。
1392 .TP
1393 .BI {, m }
1394 .\"O The preceding item is matched at most
1395 .\"O .I m
1396 .\"O times.
1397 直前の項目が
1398 .I m
1399 回以下マッチするということ。
1400 .\"O This is a \s-1GNU\s0 extension.
1401 これは \s-1GNU\s0 拡張です。
1402 .TP
1403 .BI { n , m }
1404 .\"O The preceding item is matched at least
1405 .\"O .I n
1406 .\"O times, but not more than
1407 .\"O .I m
1408 .\"O times.
1409 直前の項目が
1410 .I n
1411 回以上
1412 .I m
1413 回以下マッチするということ。
1414 .PD
1415 .\"O .SS Concatenation
1416 .SS "結合"
1417 .\"O Two regular expressions may be concatenated; the resulting
1418 .\"O regular expression matches any string formed by concatenating
1419 .\"O two substrings that respectively match the concatenated
1420 .\"O expressions.
1421 2 つの正規表現は結合することができます。
1422 結果としてできあがる正規表現は、
1423 結合対象となる部分表現にそれぞれマッチする
1424 2 つの部分文字列を結合して作られる、どんな文字列にもマッチします。
1425 .\"O .SS Alternation
1426 .SS "選択"
1427 .\"O Two regular expressions may be joined by the infix operator
1428 .\"O .BR | ;
1429 .\"O the resulting regular expression matches any string matching
1430 .\"O either alternate expression.
1431 2 つの正規表現は中置き型演算子の
1432 .BR |
1433 で繋ぐことができます。
1434 結果としてできあがる正規表現は、
1435 どちらかの部分表現にマッチするどんな文字列にもマッチします。
1436 .\"O .SS Precedence
1437 .SS "優先順位"
1438 .\"O Repetition takes precedence over concatenation, which in turn
1439 .\"O takes precedence over alternation.
1440 .\"O A whole expression may be enclosed in parentheses
1441 .\"O to override these precedence rules and form a subexpression.
1442 繰り返しは結合に優先します。また結合は選択に優先します。
1443 表現の 1 つのまとまりを括弧でくくると、その内側の式をこうした優先規則より
1444 さらに優先させることができます。
1445 括弧でくくった部分は、1 つの部分表現になるのです。
1446 .\"O .SS "Back References and Subexpressions"
1447 .SS "後方参照と部分表現"
1448 .\"O The back-reference
1449 .\"O .BI \e n\c
1450 .\"O \&, where
1451 .\"O .I n
1452 .\"O is a single digit, matches the substring
1453 .\"O previously matched by the
1454 .\"O .IR n th
1455 .\"O parenthesized subexpression of the regular expression.
1456 .I n
1457 が 1 個の数字であるような
1458 後方参照
1459 .BI \e n
1460 は、正規表現中の括弧で囲まれた
1461 .IR n
1462 番目の部分表現が前もってマッチした文字列とマッチします。
1463 .\"O .SS "Basic vs Extended Regular Expressions"
1464 .SS "基本正規表現と拡張正規表現"
1465 .\"O In basic regular expressions the meta-characters
1466 .\"O .BR ? ,
1467 .\"O .BR + ,
1468 .\"O .BR { ,
1469 .\"O .BR | ,
1470 .\"O .BR ( ,
1471 .\"O and
1472 .\"O .BR )
1473 .\"O lose their special meaning; instead use the backslashed
1474 .\"O versions
1475 .\"O .BR \e? ,
1476 .\"O .BR \e+ ,
1477 .\"O .BR \e{ ,
1478 .\"O .BR \e| ,
1479 .\"O .BR \e( ,
1480 .\"O and
1481 .\"O .BR \e) .
1482 .\"O .PP
1483 基本正規表現では、メタ文字
1484 .BR ? ,
1485 .BR + ,
1486 .BR { ,
1487 .BR | ,
1488 .BR ( ,
1489 .BR )
1490 は、その特殊な意味を失います。バックスラッシュを付けた
1491 .BR \e? ,
1492 .BR \e+ ,
1493 .BR \e{ ,
1494 .BR \e| ,
1495 .BR \e( ,
1496 .BR \e)
1497 を代わりに使用してください。
1498 .
1499 .\"O .SH "ENVIRONMENT VARIABLES"
1500 .SH "環境変数"
1501 .\"O The behavior of
1502 .\"O .B grep
1503 .\"O is affected by the following environment variables.
1504 .\"O .PP
1505 .B grep
1506 の動作は、
1507 以下に挙げる環境変数の影響を受けます。
1508 .PP
1509 .\"O The locale for category
1510 .\"O .BI LC_ foo
1511 .\"O is specified by examining the three environment variables
1512 .\"O .BR LC_ALL ,
1513 .\"O .BR LC_\fIfoo\fP ,
1514 .\"O .BR LANG ,
1515 .\"O in that order.
1516 .\"O The first of these variables that is set specifies the locale.
1517 .\"O For example, if
1518 .\"O .B LC_ALL
1519 .\"O is not set, but
1520 .\"O .B LC_MESSAGES
1521 .\"O is set to
1522 .\"O .BR pt_BR ,
1523 .\"O then the Brazilian Portuguese locale is used for the
1524 .\"O .B LC_MESSAGES
1525 .\"O category.
1526 .\"O The C locale is used if none of these environment variables are set,
1527 .\"O if the locale catalog is not installed, or if
1528 .\"O .B grep
1529 .\"O was not compiled with national language support (\s-1NLS\s0).
1530 .BI LC_ foo
1531 カテゴリのロケールは、
1532 .BR LC_ALL ,
1533 .BR LC_\fIfoo\fP ,
1534 .BR LANG
1535 という 3 つの環境変数をこの順番で調べることで決まります。
1536 この 3 つの環境変数のうち、設定されている最初のものが、
1537 .BI LC_ foo
1538 のロケールを決めるのです。
1539 たとえば、
1540 .B LC_ALL
1541 が設定されていず、
1542 .B LC_MESSAGES
1543
1544 .BR pt_BR
1545 に設定されているとしましょう。
1546 そのときは、ブラジルのポルトガル語というロケールが
1547 .B LC_MESSAGES
1548 カテゴリに使用されるわけです。
1549 こうした環境変数がまったく設定されていなかったり、ロケールの
1550 カタログがインストールされていなかったり、
1551 .B grep
1552 が各国語サポート (\s-1NLS\s0) を有効にしてコンパイルされていなかったり
1553 した場合は、C ロケールが使用されます。
1554 .\"O The shell command
1555 .\"O .B "locale \-a"
1556 .\"O lists locales that are currently available.
1557 シェルの
1558 .B "locale \-a"
1559 コマンドによって現在利用できるロケールが一覧できます。
1560 .TP
1561 .B GREP_OPTIONS
1562 .\"O This variable specifies default options
1563 .\"O to be placed in front of any explicit options.
1564 .\"O As this causes problems when writing portable scripts,
1565 .\"O this feature will be removed in a future release of
1566 .\"O .BR grep ,
1567 .\"O and
1568 .\"O .B grep
1569 .\"O warns if it is used.
1570 .\"O Please use an alias or script instead.
1571 この変数ではデフォルトのオプションを指定します。そうしたオプションは
1572 コマンドラインで明示的に指定するオプションの前に置かれます。
1573 これが移植性の高いスクリプトを書くときに問題となるため、
1574 この機能は
1575 .BR grep
1576 の将来のリリースで削除されることになっており、
1577 使用すると
1578 .B grep
1579 が警告を表示します。
1580 かわりにエイリアスやスクリプトを使ってください。
1581 .TP
1582 .B GREP_COLOR
1583 .\"O This variable specifies the color used to highlight matched (non-empty) text.
1584 .\"O It is deprecated in favor of
1585 .\"O .BR GREP_COLORS ,
1586 .\"O but still supported.
1587 .\"O The
1588 .\"O .BR mt ,
1589 .\"O .BR ms ,
1590 .\"O and
1591 .\"O .B mc
1592 .\"O capabilities of
1593 .\"O .B GREP_COLORS
1594 .\"O have priority over it.
1595 .\"O It can only specify the color used to highlight
1596 .\"O the matching non-empty text in any matching line
1597 .\"O (a selected line when the
1598 .\"O .B -v
1599 .\"O command-line option is omitted,
1600 .\"O or a context line when
1601 .\"O .B -v
1602 .\"O is specified).
1603 .\"O The default is
1604 .\"O .BR 01;31 ,
1605 .\"O which means a bold red foreground text on the terminal's default background.
1606 この変数は、パターンにマッチした (空文字列ではない) テキストを強調するために
1607 使用する色彩を指定します。
1608 .BR GREP_COLORS
1609 変数を使用する方が望ましく、この変数は非推奨なのですが、今でも
1610 使えないことはありません。
1611 .B GREP_COLORS
1612 変数の
1613 .BR mt ,
1614 .BR ms ,
1615 .B mc
1616 機能を使用している場合は、この変数による指定より、そちらのほうが
1617 優先されます。
1618 この変数によって指定できるのは、マッチする空文字列ではないテキストを
1619 強調するために、マッチする行ならどこでも使用する色彩だけなのです
1620 (マッチする行は、コマンドラインオプション
1621 .B -v
1622 を指定しなかったときは、選択される行になり、
1623 .B -v
1624 を指定したときは、前後の文脈行になります)。
1625 この変数のデフォルトの値は
1626 .BR 01;31
1627 ですが、それはターミナルのデフォルトの背景色に赤い前景色の太字で
1628 テキストを表示するということです。
1629 .TP
1630 .B GREP_COLORS
1631 .\"O Specifies the colors and other attributes
1632 .\"O used to highlight various parts of the output.
1633 .\"O Its value is a colon-separated list of capabilities
1634 .\"O that defaults to
1635 .\"O .B ms=01;31:mc=01;31:sl=:cx=:fn=35:ln=32:bn=32:se=36
1636 .\"O with the
1637 .\"O .B rv
1638 .\"O and
1639 .\"O .B ne
1640 .\"O boolean capabilities omitted (i.e., false).
1641 .\"O Supported capabilities are as follows.
1642 この変数は、出力のさまざまな部分を強調するために使用する、
1643 色彩などの属性を指定します。
1644 この変数の値はコロンで区切った機能のリストであり、
1645 デフォルトでは、
1646 .B ms=01;31:mc=01;31:sl=:cx=:fn=35:ln=32:bn=32:se=36
1647 になっていて、
1648 .B rv
1649
1650 .B ne
1651 という真偽値を取る機能は設定してありません (すなわち、false になっています)。
1652 使用できる機能は、以下のとおりです。
1653 .RS
1654 .TP
1655 .B sl=
1656 .\"O SGR substring for whole selected lines
1657 .\"O (i.e.,
1658 .\"O matching lines when the
1659 .\"O .B \-v
1660 .\"O command-line option is omitted,
1661 .\"O or non-matching lines when
1662 .\"O .B \-v
1663 .\"O is specified).
1664 .\"O If however the boolean
1665 .\"O .B rv
1666 .\"O capability
1667 .\"O and the
1668 .\"O .B \-v
1669 .\"O command-line option are both specified,
1670 .\"O it applies to context matching lines instead.
1671 .\"O The default is empty (i.e., the terminal's default color pair).
1672 選択される行全体に適用される SGR パラメータ
1673 (選択される行とは、コマンドラインで
1674 .B \-v
1675 オプションを指定しなかったときは、マッチする行、
1676 .B \-v
1677 オプションを指定したときは、マッチしない行のことです)。
1678 ただし、値に真偽値を取る
1679 .B rv
1680 機能とコマンドライン・オプションの
1681 .B \-v
1682 の両方を指定したときは、前後の文脈行扱いになるマッチする行に
1683 適用されます。
1684 デフォルトは空です (すなわち、端末のデフォルトの背景色と
1685 前景色の組み合わせ)。
1686 .TP
1687 .B cx=
1688 .\"O SGR substring for whole context lines
1689 .\"O (i.e.,
1690 .\"O non-matching lines when the
1691 .\"O .B \-v
1692 .\"O command-line option is omitted,
1693 .\"O or matching lines when
1694 .\"O .B \-v
1695 .\"O is specified).
1696 .\"O If however the boolean
1697 .\"O .B rv
1698 .\"O capability
1699 .\"O and the
1700 .\"O .B \-v
1701 .\"O command-line option are both specified,
1702 .\"O it applies to selected non-matching lines instead.
1703 .\"O The default is empty (i.e., the terminal's default color pair).
1704 前後の文脈行全体に適用される SGR パラメータ
1705 (前後の文脈行とは、コマンドラインで
1706 .B \-v
1707 オプションを指定しなかったときは、マッチしない行、
1708 .B \-v
1709 オプションを指定したときは、マッチする行のことです)。
1710 ただし、値に真偽値を取る
1711 .B rv
1712 機能とコマンドライン・オプションの
1713 .B \-v
1714 の両方を指定したときは、選択されるマッチしない行に
1715 適用されます。
1716 デフォルトは空です (すなわち、端末のデフォルトの背景色と
1717 前景色の組み合わせ)。
1718 .TP
1719 .B rv
1720 .\"O Boolean value that reverses (swaps) the meanings of
1721 .\"O the
1722 .\"O .B sl=
1723 .\"O and
1724 .\"O .B cx=
1725 .\"O capabilities
1726 .\"O when the
1727 .\"O .B \-v
1728 .\"O command-line option is specified.
1729 .\"O The default is false (i.e., the capability is omitted).
1730 コマンドラインで
1731 .B \-v
1732 が指定されているときに、
1733 .B sl=
1734
1735 .B cx=
1736 機能の意味を逆にする (入れ替える) 真偽値。
1737 デフォルトは空です (すなわち、この機能は指定されていません)。
1738 .TP
1739 .B mt=01;31
1740 .\"O SGR substring for matching non-empty text in any matching line
1741 .\"O (i.e.,
1742 .\"O a selected line when the
1743 .\"O .B \-v
1744 .\"O command-line option is omitted,
1745 .\"O or a context line when
1746 .\"O .B \-v
1747 .\"O is specified).
1748 .\"O Setting this is equivalent to setting both
1749 .\"O .B ms=
1750 .\"O and
1751 .\"O .B mc=
1752 .\"O at once to the same value.
1753 .\"O The default is a bold red text foreground over the current line background.
1754 マッチする行ならどこでも、空文字列ではないマッチするテキストに適用される
1755 SGR パラメータ
1756 (マッチする行は、コマンドラインで
1757 .B \-v
1758 オプションを指定しなかったときは、選択される行になり、
1759 .B \-v
1760 を指定したときは、前後の文脈行になります)。
1761 この機能を設定するのは、
1762 .B ms=
1763
1764 .B mc=
1765 を同時に同じ値に設定するのと同じことです。
1766 デフォルトは、カレント行の背景色に赤い前景色の太字になっています。
1767 .TP
1768 .B ms=01;31
1769 .\"O SGR substring for matching non-empty text in a selected line.
1770 .\"O (This is only used when the
1771 .\"O .B \-v
1772 .\"O command-line option is omitted.)
1773 .\"O The effect of the
1774 .\"O .B sl=
1775 .\"O (or
1776 .\"O .B cx=
1777 .\"O if
1778 .\"O .BR rv )
1779 .\"O capability remains active when this kicks in.
1780 .\"O The default is a bold red text foreground over the current line background.
1781 選択される行中の空文字列ではないマッチするテキストに適用される SGR パラメータ
1782 (この機能が使用されるのは、コマンドラインで
1783 .B \-v
1784 オプションを指定しないときだけです)。
1785 .B sl=
1786 機能
1787 .RB ( rv
1788 が設定されているときは、
1789 .B cx=
1790 機能) の効果は、この機能を使用しても、相変わらず有効です。
1791 デフォルトは、カレント行の背景色に赤い前景色の太字になっています。
1792 .TP
1793 .B mc=01;31
1794 .\"O SGR substring for matching non-empty text in a context line.
1795 .\"O (This is only used when the
1796 .\"O .B \-v
1797 .\"O command-line option is specified.)
1798 .\"O The effect of the
1799 .\"O .B cx=
1800 .\"O (or
1801 .\"O .B sl=
1802 .\"O if
1803 .\"O .BR rv )
1804 .\"O capability remains active when this kicks in.
1805 .\"O The default is a bold red text foreground over the current line background.
1806 前後の文脈行中の空文字列ではないマッチするテキストに適用される SGR パラメータ
1807 (この機能が使用されるのは、コマンドラインで
1808 .B \-v
1809 オプションが指定されているときだけです)。
1810 .B cx=
1811 機能
1812 .RB ( rv
1813 が設定されているときは、
1814 .B sl=
1815 機能) の効果は、この機能を使用しても、相変わらず有効です。
1816 デフォルトは、カレント行の背景色に赤い前景色の太字になっています。
1817 .TP
1818 .B fn=35
1819 .\"O SGR substring for file names prefixing any content line.
1820 .\"O The default is a magenta text foreground over the terminal's default background.
1821 表示される行の前にファイル名が付くとき、それに適用される SGR パラメータ。
1822 デフォルトは、端末のデフォルトの背景色にマゼンタの前景色の文字です。
1823 .TP
1824 .B ln=32
1825 .\"O SGR substring for line numbers prefixing any content line.
1826 .\"O The default is a green text foreground over the terminal's default background.
1827 表示される行の前に行番号が付くとき、それに適用される SGR パラメータ。
1828 デフォルトは、端末のデフォルトの背景色に緑の前景色の文字です。
1829 .TP
1830 .B bn=32
1831 .\"O SGR substring for byte offsets prefixing any content line.
1832 .\"O The default is a green text foreground over the terminal's default background.
1833 表示される行の前にバイトオフセットが付くとき、それに適用される SGR パラメータ。
1834 デフォルトは、端末のデフォルトの背景色に緑の前景色の文字です。
1835 .TP
1836 .B se=36
1837 .\"O SGR substring for separators that are inserted
1838 .\"O between selected line fields
1839 .\"O .RB ( : ),
1840 .\"O between context line fields,
1841 .\"O .RB ( \- ),
1842 .\"O and between groups of adjacent lines when nonzero context is specified
1843 .\"O .RB ( \-\^\- ).
1844 .\"O The default is a cyan text foreground over the terminal's default background.
1845 区切り記号に適用される SGR パラメータ。
1846 区切り記号としては、選択される行のフィールド間には
1847 .RB ' : '
1848 を置き、
1849 前後の文脈行のフィールド間には
1850 .RB ' \- '
1851 を置きます。
1852 前後の文脈行の表示が指定されているときは、隣接行グループの間に
1853 .RB ' \-\^\- '
1854 を挿入します。
1855 デフォルトは、端末のデフォルトの背景色にシアンの前景色の記号です。
1856 .TP
1857 .B ne
1858 .\"O Boolean value that prevents clearing to the end of line
1859 .\"O using Erase in Line (EL) to Right
1860 .\"O .RB ( \\\\\\33[K )
1861 .\"O each time a colorized item ends.
1862 .\"O This is needed on terminals on which EL is not supported.
1863 .\"O It is otherwise useful on terminals
1864 .\"O for which the
1865 .\"O .B back_color_erase
1866 .\"O .RB ( bce )
1867 .\"O boolean terminfo capability does not apply,
1868 .\"O when the chosen highlight colors do not affect the background,
1869 .\"O or when EL is too slow or causes too much flicker.
1870 .\"O The default is false (i.e., the capability is omitted).
1871 .\"O .PP
1872 真偽値です。通常、色付けされた項目が終わるたびに、
1873 エスケープ・シーケンス Erase in Line (EL) to Right
1874 .RB ( \\\\\\33[K )
1875 を使用して、行末まで消去しますが、
1876 .B ne
1877 を設定すると、それをやらなくなります。
1878 これは、端末が EL をサポートしていない場合に必要です。
1879 そのほか、
1880 真偽値を取る terminfo の機能
1881 .B back_color_erase
1882 .RB ( bce )
1883 を使用していない端末で、採用した強調色が背景に作用しない場合や、
1884 EL が遅すぎたり、画面にひどいチラつきを引き起こしたりする場合にも、
1885 これの設定が役に立ちます。
1886 デフォルトは false です (すなわち、この機能は設定されていません)。
1887 .PP
1888 .\"O Note that boolean capabilities have no
1889 .\"O .BR = ...
1890 .\"O part.
1891 .\"O They are omitted (i.e., false) by default and become true when specified.
1892 .\"O .PP
1893 真偽値を取る機能には
1894 .BR = ..
1895 の部分がないことに注意してください。そうした機能はデフォルトでは
1896 設定されていず (すなわち、false)、設定されたとき true になります。
1897 .PP
1898 .\"O See the Select Graphic Rendition (SGR) section
1899 .\"O in the documentation of the text terminal that is used
1900 .\"O for permitted values and their meaning as character attributes.
1901 .\"O These substring values are integers in decimal representation
1902 .\"O and can be concatenated with semicolons.
1903 使用しているテキスト端末の文書にある Select Graphic Rendition (SGR) の
1904 セクションを見て、使用できる値や、それが文字属性として使われたときの意味を
1905 調べてください。
1906 SGR パラメータの値は十進法の整数であり、セミコロンで結合することができます。
1907 .\"O .B grep
1908 .\"O takes care of assembling the result
1909 .\"O into a complete SGR sequence
1910 .\"O .RB ( \\\\\\33[ ... m ).
1911 .B grep
1912 はそうしたセミコロンで結合された数字から完全な SGR シーケンス
1913 .RB ( \\\\\\33[ ... m )
1914 を構成します。
1915 .\"O Common values to concatenate include
1916 結合される値でよく使われるものを挙げると、
1917 .\"O .B 1
1918 .\"O for bold,
1919 .B 1
1920 は太字、
1921 .\"O .B 4
1922 .\"O for underline,
1923 .B 4
1924 は下線、
1925 .\"O .B 5
1926 .\"O for blink,
1927 .B 5
1928 は点滅、
1929 .\"O .B 7
1930 .\"O for inverse,
1931 .B 7
1932 は反転です。
1933 .\"O .B 39
1934 .\"O for default foreground color,
1935 .B 39
1936 はデフォルトの前景色、
1937 .\"O .B 30
1938 .\"O to
1939 .\"O .B 37
1940 .\"O for foreground colors,
1941 .B 30
1942 から
1943 .B 37
1944 は前景色、
1945 .\"O .B 90
1946 .\"O to
1947 .\"O .B 97
1948 .\"O for 16-color mode foreground colors,
1949 .B 90
1950 から
1951 .B 97
1952 は 16 色モードの前景色、
1953 .\"O .B 38;5;0
1954 .\"O to
1955 .\"O .B 38;5;255
1956 .\"O for 88-color and 256-color modes foreground colors,
1957 .B 38;5;0
1958 から
1959 .B 38;5;255
1960 は 88 色と 256 色モードの前景色に使われます。また、
1961 .\"O .B 49
1962 .\"O for default background color,
1963 .B 49
1964 はデフォルトの背景色であり、
1965 .\"O .B 40
1966 .\"O to
1967 .\"O .B 47
1968 .\"O for background colors,
1969 .B 40
1970 から
1971 .B 47
1972 は背景色、
1973 .\"O .B 100
1974 .\"O to
1975 .\"O .B 107
1976 .\"O for 16-color mode background colors, and
1977 .B 100
1978 から
1979 .B 107
1980 は 16 色モードの背景色、
1981 .\"O .B 48;5;0
1982 .\"O to
1983 .\"O .B 48;5;255
1984 .\"O for 88-color and 256-color modes background colors.
1985 .B 48;5;0
1986 から
1987 .B 48;5;255
1988 は 88 色と 256 色モードの背景色です。
1989 .RE
1990 .TP
1991 \fBLC_ALL\fP, \fBLC_COLLATE\fP, \fBLANG\fP
1992 .\"O These variables specify the locale for the
1993 .\"O .B LC_COLLATE
1994 .\"O category,
1995 .\"O which determines the collating sequence
1996 .\"O used to interpret range expressions like
1997 .\"O .BR [a\-z] .
1998 こうした変数は
1999 .B LC_COLLATE
2000 カテゴリのロケールを指定します。
2001 .B LC_COLLATE
2002
2003 .BR [a\-z]
2004 のような範囲式を解釈するときの照合順序を決めるものです。
2005 .TP
2006 \fBLC_ALL\fP, \fBLC_CTYPE\fP, \fBLANG\fP
2007 .\"O These variables specify the locale for the
2008 .\"O .B LC_CTYPE
2009 .\"O category,
2010 .\"O which determines the type of characters,
2011 .\"O e.g., which characters are whitespace.
2012 こうした変数は
2013 .B LC_CTYPE
2014 カテゴリのロケールを指定します。
2015 .B LC_CTYPE
2016 は文字のタイプ、たとえば、空白 (whitespace) に当たるのは
2017 どの文字とどの文字か、といったことを決めるものです。
2018 .\"O This category also determines the character encoding, that is, whether
2019 .\"O text is encoded in UTF-8, ASCII, or some other encoding.  In the C or
2020 .\"O POSIX locale, all characters are encoded as a single byte and every
2021 .\"O byte is a valid character.
2022 このカテゴリーは、文字のエンコーディングも決定します。
2023 つまり、テキストのエンコーディングが UTF-8 か、ASCII か、
2024 それ以外のエンコーディングかということです。
2025 ロケールが C か POSIX の場合は、
2026 すべての文字が 1 バイトとしてエンコードされ、
2027 すべてのバイトが有効な文字となります。
2028 .TP
2029 \fBLC_ALL\fP, \fBLC_MESSAGES\fP, \fBLANG\fP
2030 .\"O These variables specify the locale for the
2031 .\"O .B LC_MESSAGES
2032 .\"O category,
2033 .\"O which determines the language that
2034 .\"O .B grep
2035 .\"O uses for messages.
2036 .\"O The default C locale uses American English messages.
2037 こうした変数は
2038 .B LC_MESSAGES
2039 カテゴリのロケールを指定します。
2040 .B LC_MESSAGES
2041
2042 .B grep
2043 がメッセージに使う言語を決めるものです。
2044 デフォルトの C ロケールでは、アメリカ英語のメッセージが使用されます。
2045 .TP
2046 .B POSIXLY_CORRECT
2047 .\"O If set,
2048 .\"O .B grep
2049 .\"O behaves as \s-1POSIX\s0 requires; otherwise,
2050 .\"O .B grep
2051 .\"O behaves more like other \s-1GNU\s0 programs.
2052 .\"O \s-1POSIX\s0 requires that options that follow file names must be
2053 .\"O treated as file names; by default, such options are permuted to the
2054 .\"O front of the operand list and are treated as options.
2055 .\"O Also, \s-1POSIX\s0 requires that unrecognized options be diagnosed as
2056 .\"O \*(lqillegal\*(rq, but since they are not really against the law the default
2057 .\"O is to diagnose them as \*(lqinvalid\*(rq.
2058 .\"O .B POSIXLY_CORRECT
2059 .\"O also disables \fB_\fP\fIN\fP\fB_GNU_nonoption_argv_flags_\fP,
2060 .\"O described below.
2061 これが設定されていると、
2062 .B grep
2063 は \s-1POSIX\s0 が要求するとおりの動作をします。
2064 設定されていない場合の動作は、ほかの \s-1GNU\s0 のプログラムに
2065 より近いものです。
2066 \s-1POSIX\s0 の規定では、ファイル名の後にオプションが現れた場合、
2067 それをファイル名として扱わなければならないことになっています。
2068 これに対して、
2069 .B grep
2070 のデフォルトでは、そうしたオプションを引き数リストの前の方に移動して、
2071 オプションとして扱います。
2072 また、\s-1POSIX\s0 の規定では、理解できないオプションは
2073 \*(lqillegal\*(rq (違法) と判断するようになっていますが、
2074 そうしたオプションも法律に違反しているわけではないので、
2075 .B grep
2076 のデフォルトでは、\*(lqinvalid\*(rq (無効) という判断を下します。
2077 .\" さらに、
2078 .\" .B POSIXLY_CORRECT
2079 .\" は、下記の \fB_\fP\fIN\fP\fB_GNU_nonoption_argv_flags_\fP を無効にします。
2080 .\" (訳注: 次項を表示しないことに合わせて、「さらに」以下の文も
2081 .\" コメントにします) 
2082 .\" .TP
2083 .\" \fB_\fP\fIN\fP\fB_GNU_nonoption_argv_flags_\fP
2084 .\"O (Here
2085 .\"O .I N
2086 .\"O is
2087 .\"O .BR grep 's
2088 .\"O numeric process ID.)  If the
2089 .\"O .IR i th
2090 .\"O character of this environment variable's value is
2091 .\"O .BR 1 ,
2092 .\"O do not consider the
2093 .\"O .IR i th
2094 .\"O operand of
2095 .\"O .B grep
2096 .\"O to be an option, even if it appears to be one.
2097 .\"O A shell can put this variable in the environment for each command it runs,
2098 .\"O specifying which operands are the results of file name wildcard
2099 .\"O expansion and therefore should not be treated as options.
2100 .\"O This behavior is available only with the \s-1GNU\s0 C library, and only
2101 .\"O when
2102 .\"O .B POSIXLY_CORRECT
2103 .\"O is not set.
2104 .\"O .
2105 .\" (ここで
2106 .\" .I N
2107 .\" は、
2108 .\" .BR grep
2109 .\" のプロセス ID 番号です) もし、この環境変数の値の
2110 .\" .IR i
2111 .\" 番目の文字が
2112 .\" .BR 1
2113 .\" だったら、
2114 .\" .B grep
2115 .\" の
2116 .\" .IR i
2117 .\" 番目の引き数がオプションのように見えても、
2118 .\" それをオプションと見なしてはいけない、ということです。
2119 .\" シェルはコマンドを実行するたびに、そのコマンドの環境にこの変数を
2120 .\" 挿入して、どの引き数がファイル名をワイルドカード展開した結果であり、
2121 .\" それ故オプションとして扱ってはいけないかを指定することができます。
2122 .\" この動作は \s-1GNU\s0 C ライブラリを使用しているときにのみ、それも、
2123 .\" .B POSIXLY_CORRECT
2124 .\" が設定されていないときにのみ、利用することができます。
2125 .\" (訳注: この環境変数は、bash 2.0 で採用されたが、問題を起こすために
2126 .\" bash 2.01 で削除されたとのことです。それ故、ユーザからは man
2127 .\" コマンドで見えないようにしておきます。getopt(3) を参照してください)
2128 .
2129 .\"O .SH "EXIT STATUS"
2130 .SH "終了ステータス"
2131 .\"O Normally the exit status is 0 if a line is selected, 1 if no lines
2132 .\"O were selected, and 2 if an error occurred.  However, if the
2133 .\"O .B \-q
2134 .\"O or
2135 .\"O .B \-\^\-quiet
2136 .\"O or
2137 .\"O .B \-\^\-silent
2138 .\"O is used and a line is selected, the exit status is 0 even if an error
2139 .\"O occurred.
2140 .\"O .
2141 通常では、選択される行が見つかったときの終了ステータスは 0 であり、
2142 見つからなかったときは 1 であり、エラーが起きた場合は 2 です。
2143 ただし、
2144 .B \-q ,
2145 .B \-\^\-quiet ,
2146 .B \-\^\-silent
2147 といったオプションが使われていて、選択される行が見つかったときは、
2148 エラーが起きたときでも終了ステータスは 0 です。
2149 .
2150 .\"O .SH COPYRIGHT
2151 .SH "著作権"
2152 Copyright 1998-2000, 2002, 2005-2016 Free Software Foundation, Inc.
2153 .PP
2154 This is free software;
2155 see the source for copying conditions.
2156 There is NO warranty;
2157 not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2158 .
2159 .\"O .SH BUGS
2160 .SH "バグ"
2161 .\"O .SS "Reporting Bugs"
2162 .SS "バグの報告"
2163 .\"O Email bug reports to
2164 .\"O .MTO bug-grep@gnu.org "the bug-reporting address" .
2165 .\"O An
2166 .\"O .URL http://lists.gnu.org/mailman/listinfo/bug-grep "email archive"
2167 .\"O and a
2168 .\"O .URL http://debbugs.gnu.org/cgi/pkgreport.cgi?package=grep "bug tracker"
2169 .\"O are available.
2170 バグ報告は
2171 .MTO bug-grep@gnu.org "バグ報告アドレス"
2172 宛に E メールで送ってください。
2173 .URL http://lists.gnu.org/mailman/listinfo/bug-grep "メールアーカイブ"
2174
2175 .URL http://debbugs.gnu.org/cgi/pkgreport.cgi?package=grep "バグトラッカー"
2176 も用意されています。
2177 .\"O .SS "Known Bugs"
2178 .SS "既知のバク"
2179 .\"O Large repetition counts in the
2180 .\"O .BI { n , m }
2181 .\"O construct may cause
2182 .\"O .B grep
2183 .\"O to use lots of memory.
2184 .\"O In addition,
2185 .\"O certain other obscure regular expressions require exponential time
2186 .\"O and space, and may cause
2187 .\"O .B grep
2188 .\"O to run out of memory.
2189 .\"O .PP
2190 .BI { n , m }
2191 を使って何度も繰り返しを行うと、
2192 .B grep
2193 は大量のメモリを消費するかもしれません。
2194 また、ほかの曖昧な正規表現にも、指数関数的な時間と
2195 メモリ空間を要するものがあり、
2196 .B grep
2197 がメモリ不足を起こすことがあります。
2198 .PP
2199 .\"O Back-references are very slow, and may require exponential time.
2200 .\"O .
2201 後方参照は非常に遅く、とんでもなく時間がかかることがあります。
2202 .PP
2203 .\"O .SH "SEE ALSO"
2204 .SH "関連項目"
2205 .\"O .SS "Regular Manual Pages"
2206 .SS "標準のマニュアルページ"
2207 awk(1), cmp(1), diff(1), find(1), gzip(1),
2208 perl(1), sed(1), sort(1), xargs(1), zgrep(1),
2209 read(2),
2210 pcre(3), pcresyntax(3), pcrepattern(3),
2211 terminfo(5),
2212 glob(7), regex(7).
2213 .\"O .SS "\s-1POSIX\s0 Programmer's Manual Page"
2214 .SS "\s-1POSIX\s0 プログラマーズ・マニュアルページ"
2215 grep(1p).
2216 .\"O .SS "Full Documentation"
2217 .SS "完全版の文書"
2218 .\"O A
2219 .\"O .URL http://www.gnu.org/software/grep/manual/ "complete manual"
2220 .\"O is available.
2221 .\"O If the
2222 .\"O .B info
2223 .\"O and
2224 .\"O .B grep
2225 .\"O programs are properly installed at your site, the command
2226 .\"O .IP
2227 .\"O .B info grep
2228 .\"O .PP
2229 .\"O should give you access to the complete manual.
2230 .\"O .
2231 .URL http://www.gnu.org/software/grep/manual/ "完全版のマニュアル"
2232 が用意されています。
2233 .B info
2234
2235 .B grep
2236 プログラムが御使用のサイトにきちんとインストールされているならば、
2237 .IP
2238 .B info grep
2239 .PP
2240 とコマンドを打ち込むことで、完備したマニュアルが読めるはずです。
2241 .\"O .SH NOTES
2242 .SH "注記"
2243 .\"O This man page is maintained only fitfully;
2244 .\"O the full documentation is often more up-to-date.
2245 .\"O .PP
2246 このマニュアルは断続的にメンテナンスされるため、
2247 完全版の文書のほうが最新であることがよくあります。
2248 .SH "訳者謝辞"
2249 この翻訳は、FreeBSD jpman Project <http://www.jp.freebsd.org/man-jp/>
2250 から Linux JM project に寄贈していただいたマニュアルを元にし、
2251 GNU grep の新しいマニュアルに合わせて、増補・改訂しています。
2252 この場を借りて、FreeBSD jpman Project の翻訳者の方々にお礼を申し上げます。
2253 .\" Work around problems with some troff -man implementations.
2254 .br