[JM:00334] [POST:DP] gnumaniak diff.1

Back to archive index

R4000 2.2 tati****@kc5*****
2011年 8月 13日 (土) 18:48:42 JST


<STATUS>
stat: DP
ppkg: gnumaniak
page: diff.1
date: 2011/08/13
mail: tati****@kc5*****
name: TACHIBANA Akira
</STATUS>

.\" You may copy, distribute and modify under the terms of the LDP General
.\" Public License as specified in the LICENSE file that comes with the
.\" gnumaniak distribution
.\"
.\" The author kindly requests that no comments regarding the "better"
.\" suitability or up-to-date notices of any info documentation alternative
.\" is added without contacting him first.
.\"
.\" (C) 2002 Ragnar Hojland Espinosa <ragna****@ragna*****>
.\"
.\"     GNU diff man page
.\"     man pages are NOT obsolete!
.\"     <ragna****@ragna*****>
.\"
.\" Japanese Version Copyright (c) 2000 NAKANO Takeo all rights reserved.
.\" Translated Sun 12 Mar 2000 by NAKANO Takeo <nakan****@apm*****>
.\" Updated & Modified Sat Jan 24 10:40:25 JST 2004
.\"         by Yuichi SATO <ysato****@yahoo*****>
.\" Updated Sat Aug 13 18:45:46 JST 2011
.\"         by TACHIBANA Akira <tati****@kc5*****>
.\"
.\"WORD:	context		コンテクスト
.\"WORD:	format		形式、[文脈によって] 整形 (する)
.\"WORD:	recursively	再帰的に
.\"WORD:	basename	ファイル名の base 部 [苦しい...]
.\"WORD:	heuristics	ヒューリスティックな手法
.\"WORD:	header		ヘッダ
.\"WORD:	gutter		のど
.\"WORD:	(in)complete	行末に改行がある (ない)
.\"WORD:	null character	ナル文字
.\"
.TH DIFF 1 "October 2002" "GNU diff Utilities 2.8.1"
.\"O .SH NAME
.\"O \fBdiff\fR \- find differences between two files
.SH 名前
diff \- 2 つのファイル間の違いを探す
.\"O .SH SYNOPSIS
.SH 書式
.B diff
[\fB\-abcdefhilnpqrstuwyBEHNPT\fR]
[\-\fILINES\fR]
[\fB\-x \fIPATTERN\fR]
[\fB\-C \fILINES\fR]
[\fB\-D \fINAME\fR]
[\fB\-F \fIREGEXP\fR] 
[\fB\-I \fIREGEXP\fR]
[\fB\-L \fILABEL\fR]
[\fB\-S \fIFILE\fR]
[\fB\-U \fILINES\fR]
[\fB\-W \fICOLUMNS\fR]
[\fB\-X \fIFILE\fR]
[\fB\-\-binary\fR]
[\fB\-\-brief\fR]
[\fB\-\-changed\-group\-format=\fIfORMAT\fR]
[\fB\-\-context\fR[\fB=\fILINES\fR]]
[\fB\-\-diff\-program=\fIPROGRAM\fR]
[\fB\-\-ed\fR]
[\fB\-\-exclude=\fIPATTERN\fR]
[\fB\-\-exclude-from=\fIFILE\fR]
[\fB\-\-expand\-tabs\fR]
[\fB\-\-forward\-ed\fR]
[\fB\-\-from\-file=\fIFILE\fR]
[\fB\-\-horizon\-lines=\fILINES\fR]
[\fB\-\-ifdef=\fINAME\fR]
[\fB\-\-ignore\-all\-space\fR]
[\fB\-\-ignore\-blank\-lines\fR]
[\fB\-\-ignore\-case\fR]
[\fB\-\-ignore\-file\-name\-case\fR]
[\fB\-\-ignore\-matching\-lines=\fIREGEXP\fR]
[\fB\-\-ignore\-space\-change\fR]
[\fB\-\-ignore\-tab\-expansion\fR]
[\fB\-\-inhibit\-hunk\-merge\fR]
[\fB\-\-initial\-tab]
[\fB\-\-label=\fILABEL\fR]
[\fB\-\-left\-column\fR]
[\fB\-\-line\-format=\fIFORMAT\fR]
[\fB\-\-minimal\fR]
[\fB\-\-new\-file\fR]
[\fB\-\-new\-group\-format=\fIFORMAT\fR]
[\fB\-\-new\-line\-format=\fIFORMAT\fR] 
[\fB\-\-no\-ignore\-file\-name\-case] 
[\fB\-\-old\-group\-format=\fIFORMAT\fR]
[\fB\-\-old\-line\-format=\fIFORMAT\fR]
[\fB\-\-paginate\fR] [\fB\-\-rcs\fR]
[\fB\-\-recursive\fR]
[\fB\-\-report\-identical\-files\fR]
[\fB\-\-sdiff\-merge\-assist\fR]
[\fB\-\-show\-c\-function\fR]
[\fB\-\-show\-function\-line=\fIREGEXP\fR]
[\fB\-\-side\-by\-side\fR]
[\fB\-\-speed\-large\-files\fR]
[\fB\-\-starting\-file=\fIFILE\fR]
[\fB\-\-strip\-trailing\-cr\fR]
[\fB\-\-supress\-common\-lines\fR]
[\fB\-\-text\fR] 
[\fB\-\-to\-file=\fIFILE\fR]
[\fB\-\-unchanged\-group\-format=\fIFORMAT\fR]
[\fB\-\-unchanged\-line\-format=\fIFORMAT\fR]
[\fB\-\-unidirectional\-new\-file]
[\fB\-\-unified\fR[\fB=\fILINES\fR]]
[\fB\-\-width=\fICOLUMNS\fR]
.I FROMFILE TOFILE

.B diff
[\fB\-v\fR] [\fB\-\-help\fR] [\fB\-\-version\fR]

.\"O .SH DESCRIPTION
.SH 説明
.\"O .B diff
.\"O compares two files and outputs descriptions of their differences.
.B diff
は 2 つのファイルを比較し、それらの違いを記述して出力する。

.\"O In the simplest case, the files to compare are
.\"O .I FROMFILE
.\"O and
.\"O .IR TOFILE .
.\"O At most one of these two file names may be
.\"O .RB ` \- ',
.\"O which tells
.\"O .B diff
.\"O to read the standard input for that file.
もっとも簡単な場合は、比較対象のファイルは
.I FROMFILE
と
.I TOFILE
である。これらのファイルのうちのどちらかは
.RB ` \- '
と指定しても良い。この時はそのファイルは標準入力から読み込まれる。

.\"O If 
.\"O .I FROMFILE
.\"O is a directory and
.\"O .I TOFILE
.\"O is not,
.\"O .B diff
.\"O compares the file in directory
.\"O .I FROMFILE
.\"O whose file name is that of
.\"O .IR TOFILE ,
.\"O and vice versa.  The non-directory file must not be
.\"O .RB ` \- '.
.I FROMFILE
がディレクトリで
.I TOFILE
がディレクトリではない場合、
.B diff
はディレクトリ
.I FROMFILE
にある、ファイル名が
.I TOFILE
のファイルを比較対象にする (逆も同様)。
ディレクトリでない方の指定を
.RB ` \- '
にすることはできない。

.\"O If both files are directories,
.\"O .B diff
.\"O compares corresponding files in both directories, in
.\"O alphabetical order; this comparison is not recursive unless the
.\"O .B \-r
.\"O or
.\"O .B \-\-recursive
.\"O option is given.
.\"O .B diff
.\"O never compares the actual contents of a directory as if it were a file.  The
.\"O file that is fully specified may not be
.\"O .RB ` \- ',
.\"O , because standard
.\"O input is nameless and the notion of ``file with the same name'' does not
.\"O apply.
両方がディレクトリのときは、
.B diff
は双方のディレクトリにある、対応するファイルを
アルファベット順にそれぞれ比較する。
比較は再帰的には行われないが、
.B \-r
または
.B \-\-recursive
オプションを指定すれば再帰的になる。
.B diff
はディレクトリの内容そのものをファイルのように比較することはしない。
フルパス指定のファイルは
.RB ` \- '
であってはならない。なぜなら標準入力には名前がないので、
「同名のファイル」という概念が使えないからである。

.\"O If the
.\"O .B \-\-from\-file=\fIFILE\fR
.\"O option is given, the number of file names
.\"O is arbitrary, and \fIFILE\fR is compared to each named file.  Similarly, if
.\"O the
.\"O .B \-\-to\-file=\fIFILE\fR
.\"O option is given, each named file is compared to \fIFILE\fR.
.B \-\-from\-file=\fIFILE\fR
オプションが与えられると、任意の数のファイル名を与えることができ、
それぞれのファイルは \fIFILE\fP と比較される。
同様に、
.B \-\-to\-file=\fIFILE\fR
オプションが与えられると、それぞれ指定されたファイルは
\fIFILE\fP と比較される。
[訳注: 2.7 にはこれらのオプションは存在しない]
.\"O .SH OPTIONS
.SH オプション
.TP
.BI \- LINES
.\"O Show
.\"O .I LINES
.\"O (an integer) lines of context.  This option does not
.\"O specify an output format by itself; it has no effect unless it is
.\"O combined with
.\"O .B \-c
.\"O or
.\"O .BR \-u .
.\"O This option is obsolete.  For proper
.\"O operation,
.\"O .B patch
.\"O typically needs at least two lines of context.
異なっている部分の前後
.I LINES
行 (整数) 分のコンテクストを表示する。
このオプションは出力形式自体の指定は行わない。
したがって
.BR \-c " や " \-u
オプションと一緒に用いないと、なんの効果も持たない。
このオプションは obsolete である。
.BR patch (1)
が正しく動作するには、少なくとも 2 行のコンテクストが必要である。
.TP
.B \-a, \-\-text
.\"O Treat all files as text and compare them line-by-line, even if they
.\"O do not seem to be text.
ファイルがテキストには見えないような場合でも、
全てのファイルをテキストとみなして 1 行ずつ比較を行う。
.TP
.B \-b, \-\-ignore\-space\-change
.\"O Ignore changes in amount of white space.  Incomplete lines are ignored.
スペースの数だけが違う場合には違いを無視する。
不完全な行は無視される。
.TP
.B \-c
.\"O Use the context output format.
context 出力形式を用いる。
.TP
.B \-d, \-\-minimal
.\"O Change the algorithm to perhaps find a smaller set of changes.  This makes
.\"O .B diff
.\"O slower (sometimes much slower).
アルゴリズムを変更し、より小さな差分が生成できるようにする。
これを使うと
.B diff
は遅くなる (非常に遅くなる場合もある)。
.TP
.B \-e, \-\-ed
.\"O Make output that is a valid
.\"O .BR ed (1)
.\"O script.
.BR ed (1)
のスクリプト形式で出力する。
.TP
.B \-f, \-\-forward\-ed
.\"O Make output that looks vaguely like an
.\"O .B ed
.\"O script but has changes in the order they appear in the file.
.B ed
のスクリプトと一見同じような出力をする。
しかし出力に現れる順序が異なる [訳注: したがって
.B ed
では使えない]。
.TP
.B \-h
.\"O This option currently has no effect; it is present for Unix
.\"O compatibility, and has been deprecated.
現在は何も効果を持たない。Unix との互換性のために存在している。
これは推奨されない。
.TP
.B \-i, \-\-ignore\-case
.\"O Ignore changes in case; consider upper- and lower-case letters
.\"O equivalent.
英大文字と小文字の違いを無視する。
.TP
.B \-l, \-\-paginate
.\"O Pass the output through
.\"O .BR pr (1)
.\"O to paginate it.
出力を
.BR pr (1)
に通してページ付けを行う。
.TP
.B \-n, \-\-rcs
.\"O Output RCS-format diffs; like
.\"O .B \-f
.\"O except that each command
.\"O specifies the number of lines affected.
RCS 形式の diff を出力する。
.B \-f
と似ているが、それぞれのコマンドは処理する行数を指定する。
.TP
.B \-p, \-\-show\-c\-function
.\"O Show which C function each change is in. This is equivalent to
.\"O `\-F'^[_a\-zA\-Z$]''.
変更がどの C 関数で行われたのかを表示する。
`\-F'^[_a\-zA\-Z$]''
と同じ。
.TP
.B \-q, \-\-brief
.\"O Report only whether the files differ, not the details of the
.\"O differences.
ファイルが違うかどうかだけを報告する。
違いの詳細は報告しない。
.TP
.B \-r, \-\-recursive
.\"O When comparing directories, recursively compare any subdirectories
.\"O found.
ディレクトリを比較するとき、
見付かったサブディレクトリをすべて再帰的に比較する。
.TP
.B \-s, \-\-report\-identical\-files
.\"O Report when two files are the same.
2 つのファイルが同じだったときも報告する。
.TP
.B \-t, \-\-expand\-tabs
.\"O Expand tabs to spaces in the output, to preserve the alignment of tabs
.\"O in the input files.
入力ファイルでのタブによる位置あわせを保存するため、
出力のタブをスペースに展開する。
.TP
.B \-u
.\"O Use the unified output format.
unified 出力形式を用いる。
.TP
.B \-w, \-\-ignore\-all\-space
.\"O Ignore white space when comparing lines.  Incomplete lines are ignored.
行を比較するときスペースを無視する。
不完全な行は無視される。
.TP
.BI "\-x " PATTERN ", \-\-exclude=" PATTERN
.\"O When comparing directories, ignore files and subdirectories whose basenames
.\"O match
.\"O .IR PATTERN .
ディレクトリを比較するとき、
ファイル名の base 部が
.I PATTERN
にマッチするファイルやサブディレクトリを無視する。
.TP
.B \-y, \-\-side\-by\-side
.\"O Use the side by side output format.
side-by-side 出力形式を用いる。
.TP
.B \-B, \-\-ignore\-blank\-lines
.\"O Ignore changes that just insert or delete blank lines.
空行を挿入・削除するだけの変更を無視する。
.TP
.BI "\-C " LINES ", \-\-context[=" LINES ]
.\"O Use the context output format, showing
.\"O .I LINES
.\"O (an integer) lines of
.\"O context, or three if
.\"O .I LINES
.\"O is not given.  For proper operation,
.\"O .B patch
.\"O typically needs at least two lines of context.
context 出力形式を用い、
.I LINES
行 (整数値) のコンテクストを表示する。
.I LINES
が与えられなければ 3 行表示する。
.B patch
が正しく動作するためには、
少なくとも 2 行のコンテクストが必要であることが多い。
.TP
.BI "\-D " NAME ", \-\-ifdef=" NAME
.\"O Make merged if-then-else format output, conditional on the preprocessor
.\"O macro
.\"O .IR NAME .
if-then-else 形式でマージされた出力を行い、
プリプロセッサの条件マクロに
.I NAME
を用いる。
.TP
.B "\-E, \-\-ignore\-tab\-expansion"
.\"O Ignores changes in whitespace due to tab expansion.
タブ展開によるスペースの変更を無視する。
.TP
.BI "\-F " REGEXP ", \-\-show\-function\-line=" REGEXP
.\"O In context and unified format, for each hunk of differences, show some
.\"O of the last preceding line that matches
.\"O .IR REGEXP .
context 形式と unified 形式において、
各差分 hunk (テキストブロック) に対し、
その前方で
.I REGEXP
にマッチした最後の行の一部を表示する。
.TP
.B \-H, \-\-speed\-large\-files
.\"O Use heuristics to speed handling of large files that have numerous
.\"O scattered small changes.  \-H short form has been deprecated.
小さな変更が大量にあるような大きなファイルを高速に扱うために、
ヒューリスティックな手法を用いる。
短縮形式 \-H は推奨されなくなった。
.TP
.BI "\-I " REGEXP ", \-\-ignore\-matching\-lines=" REGEXP
.\"O Ignore changes that just insert or delete lines that match
.\"O .IR REGEXP .
.I REGEXP
にマッチするような行を挿入・削除するだけの変更を無視する。
.TP
.BI "\-L " LABEL ", \-\-label=" LABEL
.\"O Use
.\"O .I LABEL
.\"O instead of the file name in the context format
.\"O and unified format
.\"O headers.  \-L short form has been deprecated.
context 形式と unified 形式のヘッダに、
ファイル名ではなく
.I LABEL
を用いる。
短縮形式 \-L は推奨されなくなった。
.TP
.B \-N, \-\-new\-file
.\"O In directory comparison, if a file is found in only one directory,
.\"O treat it as present but empty in the other directory.
ディレクトリを比較する際、
片方のディレクトリにのみファイルが存在していたら、
もう片方のディレクトリには同名の空っぽのファイルがあるように動作する。
.TP
.B \-P, \-\-unidirectional\-new\-file
.\"O When comparing directories, if a file appears only in the second
.\"O directory of the two, treat it as present but empty in the other.
.\"O \-P short form has been deprecated.
ディレクトリを比較する際、
2 番目のディレクトリにのみファイルが存在していたら、
1 番目のディレクトリには同名の空っぽのファイルがあるように動作する。
短縮形式 \-P は推奨されなくなった。
.TP
.BI "\-S " FILE ", \-\-starting\-file=" FILE
.\"O When comparing directories, start with the file
.\"O .IR FILE .
.\"O This is used for resuming an aborted comparison.
ディレクトリを比較する際、
.I FILE
から始める。中断した比較を続行する際に利用できる。
.TP
.B \-T, \-\-initial\-tab
.\"O Output a tab rather than a space before the text of a line in normal or
.\"O context format.  This causes the alignment of tabs in the line to look
.\"O normal.
normal 形式や context 形式で、テキストの前にスペースでなくタブを出力する。
こうすると行中でのタブによる桁揃えが普通に見える。
.TP
.BI "\-U " LINES ", \-\-unified" \fR[ = LINES \fR]
.\"O Use the unified output format, showing
.\"O .I LINES
.\"O (an integer) lines of context, or three if
.\"O .I LINES
.\"O is not given.  For proper operation,
.\"O .B patch
.\"O typically needs at least two lines of context.
unified 出力形式を用い、
.I LINES
行 (整数値) のコンテクストを表示する。
.I LINES
が与えられなければ 3 行表示する。
.B patch
が正しく動作するためには、
少なくとも 2 行のコンテクストが必要であることが多い。
.TP
.BI "\-W " COLUMNS ", \-\-width=" COLUMNS
.\"O Use an output width of
.\"O .I COLUMNS
.\"O in side by side format.
side-by-side 形式で、出力の幅を
.I COLUMNS
にする。
.TP
.BI \-X FILE ", \-\-exclude\-from=" FILE
.\"O When comparing directories, ignore files and subdirectories whose basenames
.\"O match any pattern contained in
.\"O .IR FILE .
ディレクトリを比較する際、
ファイル名の base 部が
.I FILE
のパターンのいずれかにマッチするファイルやサブディレクトリを無視する。
.TP
.B \-\-binary
.\"O Read and write data in binary mode (no effect in Linux or other POSIX hosts).
データをバイナリモードで読み書きする
(Linux やその他の POSIX ホストでは意味なし)。
.TP
.BI \-\-changed\-group\-format= FORMAT
.\"O Use
.\"O .I FORMAT
.\"O to output a line group containing differing lines from
.\"O both files in if-then-else format.
if-then-else 形式で、
両方のファイルで異なる行グループの出力に
.I FORMAT
を用いる。
.TP
.B \-\-diff\-program= \fIPROGRAM
.\"O Use an external \fIPROGRAM\fR, compatible with \fBdiff\fR, to compare files.
ファイルの比較するために \fBdiff\fR と互換性のある
外部プログラム \fIPROGRAM\fR を用いる。
.TP
.BI \-\-from\-file= FILE
.\"O Compare \fIFILE\fR with each operand; \fIFILE\fR may be a directory.
.I FILE
を各オペランドと比較する (\fIFILE\fR はディレクトリでも良い)。
[訳注: 2.7 にはこのオプションは存在しない]
.TP
.BI \-\-horizon\-lines= LINES
.\"O Do not discard the last
.\"O .I LINES
.\"O lines of the common prefix
.\"O and the first
.\"O .I LINES
.\"O lines of the common suffix.
差分をもっともコンパクトに出力するために、
違う部分の前後にある共通部分のそれぞれ
.I LINES
行を捨てずに保存する。
.TP
.B \-\-ignore\-file\-name\-case
.\"O Ignore case in filenames when comparing files, so that ``foo'' and ``Foo''
.\"O are considered the same and therefore compared with each other.
ファイルを比較する際にファイル名の大文字小文字を無視する。
そのため ``foo'' と ``Foo'' は同じとされるので、互いに比較される。
.TP
.B \-\-inhibit\-hunk\-merge
.\"O Do not shift hunk boundaries to merge adjacent hunks.
隣接する hunk の境界を移動して hunk をマージする動作を行わない。
.TP
.B \-\-left\-column
.\"O Print only the left column of two common lines in side by side format.
side-by-side 形式で、共通な行は左側の列にしか表示しない。
.TP
.BI \-\-line\-format= FORMAT
.\"O Use
.\"O .I FORMAT
.\"O to output all input lines in in-then-else format.
if-then-else 形式で、全ての入力行の出力に
.I FORMAT
を用いる。
.TP
.BI \-\-new\-group\-format= FORMAT
.\"O Use
.\"O .I FORMAT
.\"O to output a group of lines taken from just the second
.\"O file in if-then-else format.
if-then-else 形式で、
2 番目のファイルだけにある行グループの出力に
.I FORMAT
を用いる。
.TP
.BI \-\-new\-line\-format= FORMAT
.\"O Use 
.\"O .I FORMAT
.\"O to output a line taken from just the second file in
.\"O if-then-else format.
if-then-else 形式で、
2 番目のファイルだけにある行の出力に
.I FORMAT
を用いる。
.TP
.B \-\-no\-ignore\-file\-name\-case
.\"O Case in filenames is taken into account comparing files, so that names ``foo'' and
.\"O ``Foo'' are not considered the same.  See \fB\-\-ignore\-file\-name\-case\fR.
ファイルを比較する際に、ファイル名の大文字小文字を考慮する。
そのため ``foo'' と ``Foo'' は同じものとされない。
\fB\-\-ignore\-file\-name\-case\fR を参照すること。
.TP
.BI \-\-old\-group\-format= FORMAT
.\"O Use
.\"O .I FORMAT
.\"O to output a group of lines taken from just the first
.\"O file in if-then-else format.
if-then-else 形式で、
1 番目のファイルだけにある行グループの出力に
.I FORMAT
を用いる。
.TP
.BI \-\-old\-line\-format= FORMAT
.\"O Use
.\"O .I FORMAT
.\"O to output a line taken from just the first file in
.\"O if-then-else format.
if-then-else 形式で、
1 番目のファイルだけにある行の出力に
.I FORMAT
を用いる。
.TP
.B \-\-sdiff\-merge\-assist
.\"O Print extra information to help
.\"O .BR sdiff (1).
.\"O .B sdiff
.\"O uses this option when it runs
.\"O .BR diff .
.\"O This option is not intended for users to use directly.
.BR sdiff (1)
用に追加情報を表示する。
.B sdiff
が
.B diff
を実行するときにこのオプションを用いる。
通常のユーザーがこのオプションを直接指定する場合はあまり想定されていない。
.TP
.B \-\-strip\-trailing\-cr
.\"O Strips trailing CRs.  Useful when processing output from systems that use
.\"O CRLF as end of line markers.
行末の CR を取り除く。
行末のマーカとして CRLF を使うシステムの出力を処理するときに役立つ。
.TP
.B \-\-suppress\-common\-lines
.\"O Do not print common lines in side by side format.
side-by-side 形式で共通な行を表示しない。
.TP
.BI \-\-unchanged\-group\-format= FORMAT
.\"O Use
.\"O .I FORMAT
.\"O to output a group of common lines taken from both files
.\"O in if-then-else format.
if-then-else 形式で、
両方のファイルに共通な行グループの出力に
.I FORMAT
を用いる。
.TP
.BI \-\-unchanged\-line\-format= FORMAT
.\"O Use
.\"O .I FORMAT
.\"O to output a line common to both files in if-then-else
.\"O format.
if-then-else 形式で、
両方のファイルに共通な行の出力に
.I FORMAT
を用いる。
.TP
.B "\-\-help"
.\"O Print a usage message on standard output and exit successfully.
標準出力に使用方法のメッセージを出力して正常終了する。
.TP
.B \-v, \-\-version
.\"O Output the version number of
.\"O .BR diff .
.B diff
のバージョン番号を出力する。
.\"O .SH OUTPUT FORMATS
.SH 出力の形式
.\"nakano: normal format がない...
.\"O .SS Context format
.SS context 形式
.\"O The context output format starts with a two-line header, which looks
.\"O like this:
context 出力形式は 2 行のヘッダからはじまる。
これは以下のようなものである:
.sp
.nf
*** FROMFILE FROMFILE-MODIFICATION-TIME
--- TOFILE TOFILE-MODIFICATION-TIME
.fi
.sp
.\"O You can change the header's content with the 
.\"O .BI "-L " LABEL	     
.\"O Next come one or more hunks of differences; each hunk shows
.\"O one area where the files differ.  Context format hunks look like this:
.BI \-L " LABEL"
を用いるとヘッダの内容は変化する。
次に来るのは hunk (テキストブロック) である。
繰り返し登場することもある。
context 形式の hunk は以下のようなものである:
.sp
.nf
***************
*** FROMFILE-LINE-RANGE ****
  FROMFILE-LINE
  FROMFILE-LINE...
--- TOFILE-LINE-RANGE ----
  TOFILE-LINE
  TOFILE-LINE...
.fi
.sp
.\"O The lines of context around the lines that differ start with two
.\"O space characters.  The lines that differ between the two files start
.\"O with one of the following indicator characters, followed by a space
.\"O character:
異なっている行の周辺のコンテクストの各行には、
先頭に 2 つのスペースがついている。
2 つのファイル間で異なっている行には、
先頭に表示文字とスペースがつく。
.TP
.B !
.\"O A line that is part of a group of one or more lines that changed
.\"O between the two files.  There is a corresponding group of lines
.\"O marked with 
.\"O .RB ` ! '
.\"O in the part of this hunk for the other file.
2 つのファイル間で変更された部分の各行。
もう一方のファイルの対応する部分も
.RB ` ! '
でマークされて表示される。
.TP
.B +
.\"O An "inserted" line in the second file that corresponds to nothing in the
.\"O first file.
2 つめのファイルで「挿入された」行。1 つめのファイルに対応部分はない。
.TP
.B -
.\"O A "deleted" line in the first file that corresponds to nothing in the
.\"O second file.
1 つめのファイルで「削除された」行。2 つめのファイルに対応部分はない。
.PP
.\"O If all of the changes in a hunk are insertions, the lines of
.\"O .I FROMFILE
.\"O are omitted.  If all of the changes are deletions, the lines
.\"O of 
.\"O .I TOFILE
.\"O are omitted.
hunk の全ての変更が挿入であれば、
.I FROMFILE
各行は省略される。また全ての変更が削除であれば、
.I TOFILE
各行は省略される。
.\"O .SS Unified format	
.SS unified 形式
.\"O The unified output format starts with a two-line header, which looks
.\"O like this:
.sp
.nf   
--- FROMFILE FROMFILE-MODIFICATION-TIME
+++ TOFILE TOFILE-MODIFICATION-TIME
.fi
.sp
.\"O You can change the header's content with the 
.\"O .BI "-L " LABEL	     
.\"O Next come one or more hunks of differences; each hunk shows
.\"O one area where the files differ.  Unified format hunks look like this:
.BI \-L " LABEL"
を用いるとヘッダの内容は変化する。
次に来るのは hunk (テキストブロック) である。繰り返し登場することもある。
それぞれの hunk はファイルの異なっている 1 つ 1 つの部分を示している。
unified 形式の hunk は以下のようなものである:
.sp
.nf
@@ FROMFILE-RANGE TOFILE-RANGE @@
LINE-FROM-EITHER-FILE
LINE-FROM-EITHER-FILE...
.fi
.sp
.\"O The lines lines common to both files start with 1 space character.  The lines
.\"O that differ start with one of the following indicator characters:
両者で共通な行の前には 1 つのスペースが置かれる。
異なる行の前には以下の表示文字が置かれる:
.TP
.B +
.\"O A line was added here to the first file.
ここで 1 つめのファイルに行の追加が行われた。
.TP
.B -
.\"O A line was removed here from the first file.
ここで 1 つめのファイルから行の削除が行われた。
.\"O .SS Side by side format
.SS side-by-side 形式
.\"O The files are listed in two columns with a gutter between them.  The
.\"O gutter contains one of the following markers:
ファイルは 2 列に表示され、間にのど (gutter) が置かれる。
のどには以下のマーカーのいずれか 1 つが含まれる。
.TP
.B ` '
.\"O The corresponding lines are in common.  That is, either the lines
.\"O are identical, or the difference is ignored because of one of the
.\"O .B \-\-ignore
.\"O options.
対応する行が共通である。つまり、両方の行が同一であるか、
違いが
.B \-\-ignore
オプションのいずれかによって無視された。
.TP
.B |
.\"O The corresponding lines differ, and they are either both complete
.\"O or both incomplete.
対応する行が異なる。両方とも完全か、両方とも不完全かである。
.TP
.B <
.\"O The files differ and only the first file contains the line.
ファイルは異なり、1 番目のファイルにだけこの行が含まれている。
.TP
.B >
.\"O The files differ and only the second file contains the line.
ファイルは異なり、2 番目のファイルにだけこの行が含まれている。
.TP
.B (
.\"O Only the first file contains the line, but the difference is ignored.
1 番目のファイルにだけこの行が含まれているが、違いは無視される。
.TP
.B )
.\"O Only the second file contains the line, but the difference is ignored.
2 番目のファイルにだけこの行が含まれているが、違いは無視される。
.TP
.B \e
.\"O The corresponding lines differ, and only the first line is incomplete.
対応する行が異なる。1 番目の行だけに行末の改行がない。
.TP
.B /
.\"O The corresponding lines differ, and only the second line is incomplete.
.\"O Normally, an output line is incomplete if and only if the lines that
.\"O it contains are incomplete.  However, when an output line represents two
.\"O differing lines, one might be incomplete while the other is not.  In this
.\"O case, the output line is complete, but its the gutter is marked 
.\"O .RB ` \e '
.\"O if the first line is incomplete, 
.\"O .RB ` / '
.\"O if the second line is.
対応する行が異なる。2 番目の行だけに行末の改行がない。
通常出力行は、そこに含まれる行の末尾に改行がない場合に限って改行されない。
しかし、出力行が 2 行の差異を表している場合には、
片方だけに改行がない場合もあり得る。この場合出力行には改行が出力されるが、
のどのマークは 1 番目の行末に改行がなければ
.RB ` \e '
に、2 番目の行末に改行がなければ
.RB ` / '
になる。
.PP
.\"O Side by side format is sometimes easiest to read, but it has
.\"O limitations.  It generates much wider output than usual, and truncates
.\"O lines that are too long to fit.  Also, it relies on lining up output
.\"O more heavily than usual, so its output looks particularly bad if you
.\"O use varying width fonts, nonstandard tab stops, or nonprinting
.\"O characters.
.\"O You can use
.\"O .BR sdiff (1)
.\"O command to interactively merge side by side differences.
side-by-side 形式が一番読みやすいような場合もあるが、限界もある。
この形式は通常よりもずっと広い幅の出力を生成し、
長すぎる行は折り畳んでしまう。
またこの出力では通常よりも文字の整列への依存が大きくなるので、
等幅フォントを使っていなかったり、通常と異なるタブストップを使っていたり、
印字されない文字を使っていたりすると、出力が非常に醜くなる。
.\"O .SS ed(1) format
.SS ed(1) 形式
.\"O Consists of one or more hunks of differences.  The changes closest to the
.\"O ends of the files come first so that commands that change the number of
.\"O lines do not affect how 
.\"O .B ed
.\"O interprets line numbers in succeeding commands.
.\"O .B  ed 
.\"O format hunks look like this:
1 つ以上の差分 hunk から構成される。
末尾に近い方の変更が先に現れ、行数の変化が以降の
.B ed
の行番号解釈に影響しないようになっている。
.B ed
形式の hunk は以下のようなものである:
.sp
.nf
CHANGE-COMMAND
TO-FILE-LINE
TO-FILE-LINE...
\&.
.fi
.sp
.\"O Because
.\"O .B ed
.\"O uses a single period on a line to indicate the end of input, 
.\"O .B diff
.\"O protects lines of changes that contain a single period on a line by writing
.\"O two periods instead, then writing a subsequent ed' command to change the two 
.\"O periods into one.  The 
.\"O .B ed
.\"O format cannot represent an incomplete line, so if the second file ends
.\"O in a changed incomplete line,
.\"O .B diff
.\"O reports an error and then pretends that a newline was appended.
.B ed
は入力の末尾を表すためにピリオド 1 つだけの行を用いるので、
.B diff
は変更された行のうち、ピリオド 1 つだけの行を
ピリオド 2 つに変更してプロテクトし、
続けて 2 つのピリオドを 1 つにする ed コマンドを書く。
.B ed
形式は改行されていない行を表すことができない。
したがって 2 番目のファイルの最終行が変更されていて、
かつ改行されていなかった場合、
.B diff
はエラーを報告して、改行があるかのように動作する。

.\"O There are three types of change commands.  Each consists of a line
.\"O number or comma-separated range of lines in the first file and a single
.\"O character indicating the kind of change to make.  All line numbers are
.\"O the original line numbers in the file.  The types of change commands
.\"O are:
変更コマンドには 3 つの種類がある。
それぞれ、1 番目のファイルの行番号 (またはコンマ区切り指定の行範囲指定)、
続けて変更の種類を示す 1 文字の文字からなる。
行番号は、すべてファイルのオリジナルの行番号である。
変更コマンドの種類は以下の通り:
.TP
.IB L a
.\"O Add text from the second file after line \fIL\fP in the first file.  For
.\"O example, `8a' means to add the following lines after line 8 of file 1.
1 番目のファイルの \fIL\fP 行目以降に、2 番目のファイルからテキストを追加する。
例えば `8a' は、以降の行をファイル 1 の 8 行目以降に追加する。
.TP
.IB R c	
.\"O Replace the lines in range \fIR\fP in the first file with the following
.\"O lines.  Like a combined add and delete, but more compact.  For
.\"O example, `5,7c' means change lines 5-7 of file 1 to read as the
.\"O text file 2.
1 番目のファイルの行範囲 \fIR\fP を、
引き続く行で置き換える。追加と削除の組み合わせでも同じことができるが、
こちらのほうがコンパクトである。例えば `5,7c' はファイル 1 の
5 行目から 7 行目をファイル 2 から読み込んだ内容で置き換える。
.\"nakano: ちょっと to read as.. の訳として変かも。
.TP
.IB R d	
.\"O Delete the lines in range \fIR\fP from the first file.  For example,
.\"O `5,7d' means delete lines 5-7 of file 1.
1 番目のファイルの行範囲 \fIR\fP を削除する。
例えば `5,7d' はファイル 1 の 5 行目から 7 行目までを削除する。
.PP
.\"O .B diff
.\"O can produce output that is like an 
.\"O .B ed
.\"O script, but with hunks in forward (front to back) order.  The format of the
.\"O commands is also changed slightly: command characters precede the lines they
.\"O modify, spaces separate line numbers in ranges, and no attempt is made
.\"O to disambiguate hunk lines consisting of a single period.  Like 
.\"O .B ed
.\"O format, forward 
.\"O .B ed 
.\"O format cannot represent incomplete lines.
.B diff
は
.B ed
スクリプトのような出力で、かつ各 hunk が forward 方向 (先頭から末尾へ)
のような出力も生成できる。コマンドの形式もちょっと変化している。
コマンド文字が、修正する行や行範囲の先に来るのである。
また、ピリオド 1 つだけの行を特別扱いすることもしない。
.\"nakano: 意訳しすぎだろうか(^^;
.B ed
形式と同様に、forward
.B ed
形式も改行していない行を表すことはできない。

.\"O Forward
.\"O .B ed
.\"O format is not very useful, because neither
.\"O .B ed
.\"O nor
.\"O .B patch
.\"O can apply diffs in this format.  It exists mainly for  compatibility with
.\"O older versions of
.\"O .BR diff .
forward
.B ed
形式はあまり便利ではない。なぜなら
.B ed
も
.B patch
もこの形式の diff を用いることができないからである。
これは主に古いバージョンの
.B diff
との互換性のために存在している。
.\"O .SS RCS format
.SS RCS 形式
.\"O The RCS output format is designed specifically for use by the
.\"O Revision Control System, which is a set of free programs used for
.\"O organizing different versions and systems of files. It is like the forward
.\"O .B ed
.\"O format, but it can represent arbitrary changes to the contents of a file
.\"O because it avoids the problems with lines consisting of a single period and
.\"O with incomplete lines.  Instead of ending text sections with a line
.\"O consisting of a single period, each command specifies the number of
.\"O lines it affects; a combination of the
.\"O .RB ` a '
.\"O and 
.\"O .RB ` d '
.\"O commands are used
.\"O instead of 
.\"O .RB ` c '.
.\"O Also, if the second file ends in a changed incomplete line, then the output
.\"O also ends in an incomplete line.
RCS 出力形式は Revision Control System (RCS)
で用いるために特別に設計されたものである。
RCS はバージョンやシステムの異なるファイルを扱うための、
フリーなプログラムセットである。
この形式は forward
.B ed
形式と似ているが、
ピリオド 1 つの行や改行していない行の問題を回避しているので、
ファイル内容の任意の変更を表すことができる。
テキストセクションをピリオド 1 つの行で終わるのではなく、
それぞれのコマンドで、適用する行数を指定しているのである。また
.RB ` c '
コマンドの代わりに
.RB ` a "' と `" d '
の組み合わせを用いている。
さらに 2 番目のファイルの末尾が変更されていて、
かつ改行で終わっていない場合には、
出力の末尾も改行されない状態で終わる。
.SH IF\-THEN\-ELSE
.\"O .SS C source format
.SS C ソース形式
.\"O You can use 
.\"O .B diff
.\"O to merge two files of C source code.  The output in this format contains all
.\"O the lines of both files.  Lines common to both files are output just once;
.\"O the differing parts are separated by the C preprocessor directives 
.\"O .BI "#ifdef " NAME
.\"O or
.\"O .B #ifndef 
.\"O .IR NAME ,
.\"O ,BR #else ", and " #endif .
.\"O When compiling the output, you select which version to use by either
.\"O defining or leaving undefined the macro
.\"O .IR NAME .
.B diff
を用いて 2 ファイルの C ソースコードをマージすることもできる。
この出力形式には、両方のファイルの行がすべて含まれる。
両方のファイルに共通な行は一度しか登場しない。
異なる部分は C プリプロセッサの指定を用いて分離される。
.BI "#ifdef " NAME
または
.B #ifndef 
.IR NAME ,
,BR #else ", and " #endif
である。
出力をコンパイルするとき、マクロ
.I NAME
を定義したり、未定義のままにすることによって、
どちらのバージョンを使うかを選択できる。
 
.\"O For example, if you change an instance of `wait (&s)' to `waitpid
.\"O (-1, &s, 0)' and then merge the old and new files with the
.\"O `\fB--ifdef=\fIHAVE_WAITPID\fR' option, then the affected part of your code 
.\"O might look like this:
例えば、`wait (&s)' というインスタンスを `waitpid (-1, &s, 0)'
に変更し、新旧のファイルを
`\fB--ifdef=\fIHAVE_WAITPID\fR' オプションによってマージすると、
影響を受けた部分のコードは以下のようになるだろう:
.sp
.nf
    do {
 #ifndef HAVE_WAITPID
          if ((w = wait (&s)) < 0 && errno != EINTR)
 #else /* HAVE_WAITPID */
          if ((w = waitpid (-1, &s, 0)) < 0  &&  errno != EINTR)
 #endif /* HAVE_WAITPID */
          return w;
    } while (w != child);
.fi
.\"O .SS Group formats
.\"nakano: "Line group formats" の間違いだろう.
.SS 行グループ形式
.\"O Line group formats let you specify formats suitable for many
.\"O applications that allow if-then-else input, including programming
.\"O languages and text formatting languages.  A line group format specifies
.\"O the output format for a contiguous group of similar lines.
行グループ形式を用いると、
if-then-else 入力を受け入れる多くのアプリケーションに適した形式を指定できる。
例えばプログラミング言語や文書整形言語などが挙げられる。
行グループ形式は、
似ている行からなる隣接したグループの出力形式を指定する。

.\"O For example, the following command compares the TeX files `old' and
.\"O `new', and outputs a merged file in which old regions are surrounded by
.\"O `\ebegin{em}'-`\eend{em}' lines, and new regions are surrounded by
.\"O `\ebegin{bf}'-`\eend{bf}' lines.
例えば、以下のコマンドは TeX ファイル `old' と `new' を比較し、
old の部分を `\ebegin{em}'-`\eend{em}' で囲み、
new の部分を `\ebegin{bf}'-`\eend{bf}' で囲んでマージしたかたちで出力する。
.sp
.nf
 diff \e
    --old-group-format='\ebegin{em}
 %<\eend{em}
 '  \e
    --new-group-format='\ebegin{bf}
 %>\eend{bf}
 '  \e
    old new
.fi
.sp						       
.\"O The following command is equivalent to the above example, but it is a
.\"O little more verbose, because it spells out the default line group formats.
以下のコマンドも上記の例と同じだが、やや記述が多い。
デフォルトの行グループ形式も指定しているからである。
.sp
.nf
 diff \e
    --old-group-format='\ebegin{em}
 %<\eend{em}
 ' \e
    --new-group-format='\ebegin{bf}
 %>\eend{bf}
 ' \e
    --unchanged-group-format='%=' \e
    --changed-group-format='\ebegin{em}
 %<\eend{em}
 \ebegin{bf}
 %>\eend{bf}
 '  \e
    old new
.fi
.sp
.\"O Here is a more advanced example, which outputs a diff listing with headers
.\"O containing line numbers in a "plain English" style. 
次にもう少し進んだ例を紹介する。これは差分リストを、
 "plain English" スタイルで行番号を書いたヘッダとともに出力する。
.sp
.nf
 diff \e
    --unchanged-group-format='' \e
    --old-group-format='-------- %dn line%(n=1?:s) deleted at %df:
 %<' \e
    --new-group-format='-------- %dN line%(N=1?:s) added after %de:
 %>' \e
    --changed-group-format='-------- %dn line%(n=1?:s) changed at %df:
 %<-------- to:
 %>' \e
    old new
.fi
.sp
.\"O To specify a line group format, use \fBdiff\fR with one of the options listed
.\"O below.  You can specify up to four line group formats, one for each kind of
.\"O line group.  You should quote \fIFORMAT\fR, because it typically contains
.\"O shell metacharacters.
行グループ形式を指定するには、
.B diff
を以下のオプションのどれか 1 つを指定して実行する。
4 つまでの行グループ形式を指定でき、
各指定がそれぞれ行グループ 1 つに対応する。
.I FORMAT
にはシェルのメタキャラクタが入っていることが多いので、
クォートするべきであろう。
.TP
.BI \-\-old-group\-format= FORMAT
.\"O These line groups are hunks containing only lines from the first file.  The 
.\"O default old group format is the same as the changed group format if it is
.\"O specified; otherwise it is a format that outputs the line group as-is.
これらの行グループは 1 番目のファイルだけにある行からなる hunk である。
デフォルトの old グループ形式は、changed グループ形式が指定されていれば
それと同じになる。されていなければ行グループはそのままのかたちで出力される。
.TP
.BI \-\-new-group\-format= FORMAT
.\"O These line groups are hunks containing only lines
.\"O from the second file.  The default new group format is same as the the changed
.\"O group format if it is specified; otherwise it is a format that outputs the line
.\"O group as-is.
これらの行グループは 2 番目のファイルだけにある行からなる hunk である。
デフォルトの new グループ形式は、changed グループ形式が指定されていれば
それと同じになる。されていなければ行グループはそのままのかたちで出力される。
.TP
.BI \-\-changed\-group\-format= FORMAT
.\"O These line groups are hunks containing lines from both files.  The default
.\"O changed group format is the concatenation of the old and new group formats.
これらの行グループは両方のファイルの行からなる hunk である。
デフォルトの changed グループ形式は、
old グループと new グループの形式を連結したものである。
.TP
.BI \-\-unchanged\-group\-format= FORMAT
.\"O These line groups contain lines common to both files.  The default unchanged
.\"O group format is a format that outputs the line group as-is.
.\"O .SS Group conversions
これらの行グループは両方のファイルに共通の行からなる hunk である。
デフォルトの unchanged グループ形式は、
行グループをそのままのかたちで出力するものである。
.SS グループ変換
.TP
.B %<
.\"O stands for the lines from the first file, including the trailing
.\"O newline.  Each line is formatted according to the old line format
1 番目のファイルからの行を意味する。行末尾の改行も含む。
各行は old 行形式によって整形される。
.TP
.B %>
.\"O stands for the lines from the second file, including the trailing
.\"O newline.  Each line is formatted according to the new line format.
2 番目のファイルからの行を意味する。行末尾の改行も含む。
各行は new 行形式によって整形される。
.TP
.B %=
.\"O stands for the lines common to both files, including the trailing
.\"O newline.  Each line is formatted according to the unchanged line format.
両方のファイルで共通な行を意味する。行末尾の改行も含む。
各行は unchanged 行形式によって整形される。
.TP
.B %%
.\"O stands for `%'.
`%' を表す。
.TP
.B %c'\fIC\fB''
.\"O where 
.\"O .I C
.\"O is a single character, stands for
.\"O .IR C ".  " C
.\"O may not be a backslash or an apostrophe.  For example, `%c':'' stands for a
.\"O colon, even inside the then-part of an if-then-else format, which a colon
.\"O would normally terminate.
ここで
.I C
は文字 1 文字で、\fIC\fR を表す。
.I C
にバックスラッシュやアポストロフィは指定できない。
例えば `%c':'' はコロンを表し、これは if-then-else 形式の
then 部分でもコロンとして解釈される。通常はコロンは
then 部分の終わりとして扱われる。
.TP
.B %c'\eO''
.\"O where
.\"O .I O
.\"O is a string of 1, 2, or 3 octal digits, stands for the
.\"O character with octal code
.\"O .IR O .
.\"O For example, %c'\e0'' stands for a null character.
ここで
.I 0
は 1 桁から 3 桁までの 8 進数字であり、8 進のコード
.I 0
に対応する文字を表す。例えば `%c'\e0'' はナル文字になる。
.TP
.BI ( A = B ? T : E )
.\"O If 
.\"O .I A
.\"O equals
.\"O .I B
.\"O then
.\"O .I T
.\"O else
.\"O .IR E .
.\"O .I A
.\"O and
.\"O .I B
.\"O are each either a decimal constant or a single letter interpreted as above.
.\"O This format spec is equivalent to 
.\"O .IR T " if " A "'s value equals " B "'s; otherwise it is equivalent to " E .
.IR A " が " B
に等しい場合は
.IR T 、
等しくない場合は
.IR E 。
.IR A " と " B
はそれぞれ 10 進数の定数か、上記のように解釈される文字 1 つである。
この形式指定は
.IR A " の値が " B " と等しければ " T " と等価であり、
それ以外の場合は
.I E
と等価である。

.\"O For example, `%(N=0?no:%dN) line%(N=1?:s)' is equivalent to no
.\"O lines' if N (the number of lines in the group in the the new file)
.\"O is 0, to 1 line' if N is 1, and to %dN lines' otherwise.
例えば `%(N=0?no:%dN) line%(N=1?:s)' は
N (new ファイルからのグループの行数) が 0 なら `no lines' となり、
N が 1 なら `1 line' となり、それ以外の場合は `%dN lines' となる。
.TP
.I FN
.\"O where F is a 
.\"O .BR printf (3)
.\"O conversion specification and 
.\"O .I N
.\"O is one of the following letters, stands for 
.\"O .IR N "'s value formatted with " F .
ここで
.I F
は
.BR printf (3)
の変換指定で、
.I N
は以下の文字のどれかである。
.RI 「 F " で整形された " N " の値」
を表す。
.I 
.RS
.TP
.B e
.\"O The line number of the line just before the group in the old file.
old ファイルからのグループの直前の行の行番号。
.TP
.B f
.\"O The line number of the first line in the group in the old file; equals E + 1.
old ファイルからのグループの最初の行番号。e + 1 に等しい。
.TP
.B l
.\"O The line number of the last line in the group in the old file.
old ファイルからのグループの末尾の行番号。
.TP
.B m
.\"O The line number of the line just after the group in the old file; equals L + 1.
old ファイルからのグループの直後の行の行番号。l + 1 に等しい。
.TP
.B n
.\"O The number of lines in the group in the old file; equals L - F + 1.
old ファイルからのグループの行数。l - f + 1 に等しい。
.TP
.B E, F, L, M, N
.\"O Likewise, for lines in the new file.
上記と同様の new ファイルからのグループのもの。
.RE
.sp
.\"O The 
.\"O .B printf
.\"O conversion specification can be 
.\"O .BR %d ", " %o ", " %x ", or " %X ,
.\"O specifying decimal, octal, lower case hexadecimal, or upper
.\"O case hexadecimal output respectively.  After the 
.\"O .RB ` % '
.\"O the following options can appear in sequence: a 
.\"O .RB ` - '
.\"O specifying left-justification; an integer specifying the minimum field width;
.\"O and a period followed by an optional integer specifying the
.\"O minimum number of digits.  For example, `%5dN' prints the number
.\"O of new lines in the group in a field of width 5 characters, using the 
.\"O .B printf
.\"O format "%5d"'.
.B printf
変換指定には
.BR %d ", " %o ", " %x ", " %X 
(それぞれ 10 進, 8 進, 小文字 16 進, 大文字 16 進) が使える。
.RB ` % '
の後には以下のオプションを順に指定できる。
.RB ` - '
(左詰めの指定)、整数 (フィールドの最低幅)、
ピリオドと数値 (数値は省略可; 桁数の最小値) である。
例えば `%5dN' は new ファイルからのグループの行数を、
5 文字幅のフィールドに、
.B printf
の "%5d" 書式を用いて表示する。
.\"O .SS Line group format
.\"nakano: "Line format" の間違いだろう
.SS 行形式
.\"O Line formats control how each line taken from an input file is
.\"O output as part of a line group in if-then-else format.
行形式は、入力から取得された各行を if-then-else 形式の
行グループとして出力される際の制御を行う。
   
.\"O For example, the following command outputs text with a one-column
.\"O change indicator to the left of the text.  The first column of output
.\"O is `-' for deleted lines, `|' for added lines, and a space for
.\"O unchanged lines.  The formats contain newline characters where newlines
.\"O are desired on output.
例えば、以下のコマンドは、テキストの左に変更表示の 1 文字を表示して
テキストを出力する。出力の最初の桁は、削除行では `-'、
追加行では `|' となり、変更されなかった行ではスペースとなる。
この形式では、改行が必要な部分には改行を入れて出力する。
      
 diff \e
    --old-line-format='-%l
 ' \e
    --new-line-format='|%l
 ' \e
    --unchanged-line-format=' %l
 ' \e
   old new

.\"O To specify a line format, use one of the following options.  You
.\"O should quote \fIFORMAT\fR, since it often contains shell metacharacters.
行形式を指定するには、以下のオプションのどれかを用いる。
.I FORMAT
にはシェルのメタキャラクタが入っていることが多いので、
クォートするべきであろう。
.TP
.BI \-\-old-line-format= FORMAT
.\"O Formats lines just from the first file.
1 番目のファイルからの行だけを整形する。
.TP
.BI \-\-new\-line\-format= FORMAT
.\"O Formats lines just from the second file.
2 番目のファイルからの行だけを整形する。
.TP
.BI \-\-unchanged\-line\-format= FORMAT
.\"O Formats lines common to both files.
両方のファイルに共通の行を整形する。
.TP
.BI \-\-line\-format= FORMAT
.\"O Formats all lines; in effect, it sets all three above options simultaneously.
全ての行を整形する。上記の全てのオプションを指定した場合に等しい。
.PP
.\"O In a line format, ordinary characters represent themselves; conversion
.\"O specifications start with
.\"O .RB ` % '
.\"O and have  forms.
行形式では、普通の文字はそれ自身を表す。変換指定は
.RB ` % '
で始まり、以下の形式をとる:
.TP
.B %l
.\"O stands for the the contents of the line, not counting its trailing
.\"O newline (if any).  This format ignores whether the line is incomplete.
行の内容を意味する。行末尾の改行はあっても含まない。
この形式では、行に改行があるかどうかは無視される。
.TP
.B %L
.\"O stands for the the contents of the line, including its trailing newline (if
.\"O any).  If a line is incomplete, this format preserves its incompleteness.
行の内容を意味する。行末尾の改行があればそれも含む。
行に改行がなければ、改行はないままになる。
.TP
.B %%
.\"O stands for `%'.
`%' を表す。
.TP
.B %c'\fIC\fB''
.\"O where 
.\"O .I C
.\"O is a single character, stands for
.\"O .IR C ".  " C
.\"O may not be a backslash or an apostrophe.  For example, `%c':'' stands for a
.\"O colon.
ここで
.I C
は文字 1 文字で、\fIC\fR を表す。
.I C
にバックスラッシュやアポストロフィは指定できない。
例えば `%c':'' はコロンを表し、これは if-then-else 形式の
then 部分でもコロンとして解釈される。通常はコロンは
then 部分の終わりとして扱われる。
.TP
.B %c'\eO''
.\"O where
.\"O .I O
.\"O is a string of 1, 2, or 3 octal digits, stands for the
.\"O character with octal code
.\"O .IR O .
.\"O For example, %c'\e0'' stands for a null character.
ここで
.I 0
は 1 桁から 3 桁までの 8 進数字であり、8 進のコード
.I 0
に対応する文字を表す。例えば `%c'\e0'' はナル文字になる。
.TP
.I Fn
.\"O where 
.\"O .I F
.\"O is a 
.\"O .B printf conversion specification, stands for the line number formatted with
.\"O .IR F .
.\"O For example, `%.5dn' prints the line number using the format `%.5d'.  For
.\"O more on printf conversion specifications, read the Group Format subsection
.\"O above. 
ここで
.I F
は
.BR printf (3)
の変換指定で、
.I F
により整形された行番号を表す。
例えば `%.5dN' は行番号を `%.5d' という書式で整形して表示する。
printf 変換指定の詳細は、上記の行グループ形式のサブセクションを見よ。
.PP
.\"O The default line format is 
.\"O .RB ` %l '
.\"O followed by a newline character.  If the input contains tab characters and
.\"O it is important that they line up on output, you should ensure that `%l' or
.\"O %L' in a line format is just after a tab stop (e.g. by preceding %l' or %L'
.\"O with a tab character), or you should use the \fB\-t\fR option.
デフォルトの行形式は
.RB ` %l '
に改行文字を続けたものである。入力にタブ文字があり、
それが出力行の桁揃えに重要である場合には、`%l' や `%L' の行指定を
タブストップの直後に置くとよい
(すなわち `%l' や `%L' の前にタブ文字を置けばよい)。
あるいは
.B \-t
オプションを用いるのもよいだろう。

.\"O Taken together, the line and line group formats let you specify many
.\"O different formats.  For example, the following command uses a format
.\"O similar to diff's normal format.  You can tailor this command to get
.\"O fine control over diff's output.
行形式と行グループ形式を同時に用いると、様々な形式指定が可能となる。
例えば、以下のコマンドは diff の通常の形式と似た形式の指定である。
これを修正すれば、diff の出力を微調整することが可能になる。
.sp
.nf
 diff \e
    --old-line-format='< %l
 ' \e
    --new-line-format='> %l
 ' \e
    --old-group-format='%df%(f=l?:,%dl)d%dE
 %<' \e
    --new-group-format='%dea%dF%(F=L?:,%dL)
 %>' \e
    --changed-group-format='%df%(f=l?:,%dl)c%dF%(F=L?:,%dL)
 %<---
 %>' \e
    --unchanged-group-format='' \e
    old new
.fi
.\"O .SH COMPARING DIRECTORIES
.SH ディレクトリの比較
.\"O When both file name arguments to \fBdiff\fR are directories, it compares
.\"O each file that is contained in both directories, examining file names in
.\"O alphabetical order.  Normally it is silent about pairs of files that contain
.\"O no differences, but if you use the \fB\-s\fR option, it reports pairs of 
.\"O identical files.  Normally \fBdiff\fR reports subdirectories common to both
.\"O directories without comparing subdirectories' files, but if you use the 
.\"O \fB\-r\fR option, it compares every corresponding pair of files in the
.\"O directory trees, as many levels deep as they go.
.B diff
への 2 つの引数がディレクトリだった場合、
両方のディレクトリにそれぞれのファイルが、
ファイル名のアルファベット順に比較される。
通常はファイルのペアに違いが全くなければ、何も出力しない。
しかし \fB\-s\fR オプションを用いると、同一のファイルも報告する。
両方のディレクトリに同名のサブディレクトリがあると、
通常
.B diff
は報告だけしてサブディレクトリ以下のファイルは比較しない。
しかし \fB\-r\fR オプションを用いると、
ディレクトリツリーを辿れる限り、対応する全てのファイルを比較する。

.\"O For file names that are in only one of the directories, \fBdiff\fR
.\"O normally does not show the contents of the file that exists; it reports
.\"O only that the file exists in that directory and not in the other.  You
.\"O can make \fBdiff\fR act as though the file existed but was empty in the
.\"O other directory, so that it outputs the entire contents of the file that
.\"O actually exists.  (It is output as either an insertion or a deletion,
.\"O depending on whether it is in the first or the second directory given.)
.\"O To do this, use the \fB\-N\fR option.
片方のディレクトリだけにあるファイルに対しては、
.B diff
は通常存在するファイルの内容を表示せず、
ファイルが片方にあって他方にはないことだけを報告する。
.B diff
の振舞いを変えて、
他方のディレクトリにもファイルが空の状態で存在するかのように
動作させることもできる。すなわち
.B diff
は実際に存在するファイルの内容をすべて出力する。
(この出力は、ファイルが第 1 ディレクトリにあれば削除、
第 2 ディレクトリにあれば挿入となる。)
この指定には
.B \-N
オプションを使う。

.\"O If the older directory contains one or more large files that are not
.\"O in the newer directory, you can make the patch smaller by using the
.\"O .B \-P
.\"O option instead of 
.\"O .BR \-N .
.\"O This option is like 
.\"O .B \-N
.\"O except that it only inserts the contents of files that appear in the second
.\"O directory but not the first (that is, files that were added).  At the top of
.\"O the patch, write instructions for the user applying the patch to remove the
.\"O files that were deleted before applying the patch.  
古いほうのディレクトリに大きなファイルがあって、
新しいほうにはない場合、
.BR \-N " オプションの代わりに "  \-P
オプションを用いるとパッチの大きさを小さくできる。
.BR \-P " オプションは " \-N
オプションと似ているが、第 2 ディレクトリにあるファイルの内容だけを
出力に挿入し、第 1 ディレクトリだけにあるファイルは無視する
(すなわち、追加されたファイルだけを扱う)。
そして、パッチを当てる前に消去されたファイルを削除するよう、
パッチの先頭にパッチを当てるユーザーへの指示を書く。

.\"O To ignore some files while comparing directories, use the 
.\"O \fB\-x \fIPATTERN\fR option.  Unlike in the shell, a period at the start of
.\"O the base of a file name matches a wildcard at the start of a pattern.  You
.\"O should enclose \fIPATTERN\fR in quotes so that the shell does not expand it.
.\"O For example, the option `\-x '*.[ao]'' ignores any file whose name ends with
.\"O `.a' or `.o'. This option accumulates if you specify it more than once.  For
.\"O example, using the options `-x 'RCS' -x '*,v'' ignores any file or
.\"O subdirectory whose base name is `RCS' or ends with `,v'.
ディレクトリの比較時に特定のファイルを無視させるには、
.BI \-x  " PATTERN"
オプションを用いる。シェルとは異なり、ファイル名の先頭のピリオドは、
パターン先頭のワイルドカードにマッチする。
シェルによって展開されないよう、
.I PATTERN
はクォート記号で囲うべきである。
例えば `\-x '*.[ao]'' は `.a' や `.o'
で終わる名前のファイルをすべて無視する。
このオプションは、複数指定するとそれぞれが有効になる。
例えば `\-x 'RCS' \-x '*,v'' というオプションを指定すると、
ファイル名が `RCS' だったり `*,v' で終わるような
ファイルとサブディレクトリをすべて無視する。
.\"O .SH DIAGNOSTICS
.SH 返り値
.\"O .B diff
.\"O exits with one of the following values:
.B diff
は以下の値のどれかで終了する:
.TP
.B 0
.\"O No differences were found.
全く変更がなかった。
.TP
.B 1
.\"O Some difference was found.
変更があった。
.TP
.B 2
.\"O Some error occurred.
何らかのエラーが起こった。
.\"O .SH SEE ALSO
.SH 関連項目
.\"O cmp(1), comm(1), diff3(1), ed(1), patch(1), pr(1), sdiff(1).
.BR cmp (1),
.BR comm (1),
.BR diff3 (1),
.BR ed (1),
.BR patch (1),
.BR pr (1),
.BR sdiff (1)
.\"O .SH NOTES
.SH 注意
.\"O Report bugs to bug-g****@gnu*****.
.\"O Page updated by Ragnar Hojland Espinosa <ragna****@ragna*****>
プログラムのバグについては bug-g****@gnu***** へ報告してください。
ページの更新は Ragnar Hojland Espinosa
<ragna****@ragna*****> が行っています。




linuxjm-discuss メーリングリストの案内
Back to archive index