sourCEntral - mobile manpages

pdf

WDIFF

NAME

wdiff − display word differences between text files

SYNOPSIS

wdiff [ option ... ] old_file new_file

COPYRIGHT

Copyright (C) 1992 Free Software Foundation, Inc.

DESCRIPTION

wdiff compares two files, finding which words have been deleted or added to old_file to get new_file. A word is anything between whitespace. The output is collected and used to produce an annotated copy of new_file on standard output. Suitable annotations produce a nice display of word differences between the original files.

wdiff will exit with a status of 0 if no differences were found, a status of 1 if any differences were found, or a status of 2 for any error.

Usually underlining is used to mark deleted text, while bold or reverse video is used to mark inserted text; these defaults may be over-ridden by command line options. deleted text refers to text in old_file which is not in new_file, while inserted text refers to text on new_file which is not in old_file.

OPTIONS

−−help

Has the same effect as −h.

−h

Print an informative help message describing the options.

−−version

Has the same effect as −V.

−V

Print the version number of wdiff on the standard error output.

−−no−deleted

Has the same effect as −1.

−1

Avoid producing deleted words on the output. If neither −1 or −2 is selected, the original right margin may be exceeded for some lines.

−−no−inserted

Has the same effect as −2.

−2

Avoid producing inserted words on the output. If neither −1 or −2 is selected, the original right margin may be exceeded for some lines.

−−no−common

Has the same effect as −3.

−3

Avoid producing common words on the output. When this option is not selected, common words and whitespace are taken from new_file. When selected, differences are separated from one another by lines of dashes. Moreover, if this option is selected at the same time as −1 or −2, then none of the output will have any emphasis − i.e. no bold or underlining. Finally, if this option is not selected, but both −1 and −2 are, then sections of common words between differences are separated by lines of dashes.

−−statistics

Has the same effect as −s.

−s

On completion, for each file, the total number of words, the number of common words between the files, the number of words deleted or inserted and the number of words that have changed is output. (A changed word is one that has been replaced or is part of a replacement.) Except for the total number of words, all of the numbers are followed by a percentage relative to the total number of words in the file.

−−auto-pager

Has the same effect as −a.

−a

A pager is interposed whenever the wdiff output is directed to the user’s terminal. Without this option, no pager will be called; the user is then responsible for explicitly piping wdiff output into a pager if required.

The pager is selected by the value of the PAGER environment variable when wdiff is run. If PAGER is not defined at run time, then a default pager, selected at installation time, will be used instead. A defined but empty value of PAGER means no pager at all.

When a pager is interposed through the use of this option, one of the options −l or −t is also selected, depending on whether the string "less" appears in the pager’s name or not.

It is often useful to define wdiff as an alias for wdiff -a. However, this "hides" the normal wdiff behaviour. The default behaviour may be restored simply by piping the output from wdiff through cat. This dissociates the output from the user terminal.

−−printer

Has the same effect as −p.

−p

Use over-striking to emphasize parts of the output. Each character of the deleted text is underlined by writing an underscore _ first, then a backspace and then the letter to be underlined. Each character of the inserted text is emboldened by writing it twice, with a backspace in between. This option is not selected by default.

−−less-mode

Has the same effect as −l.

−l

Use over-striking to emphasize parts of output. This option works as option −p, but also over-strikes whitespace associated with inserted text. less shows such whitespace using reverse video. This option is not selected by default. However, it is automatically turned on whenever wdiff launches less. (See option −a.)

This option is commonly used in conjunction with less:

wdiff -l old_file new_file | less

−−terminal

Has the same effect as −t.

−t

Force the production of termcap strings for emphasising parts of output, even if the standard output is not associated with a terminal. The TERM environment variable must contain the name of a valid termcap entry. If the terminal description permits, underlining is used for marking deleted text, while bold or reverse video is used for marking inserted text. This option is not selected by default. However, it is automatically turned on whenever wdiff launches a pager, and it is known that the pager is not less. (See option −a.)

This option is commonly used when wdiff output is not redirected, but sent directly to the user’s terminal, as in:

wdiff -t old_file new_file

A common kludge uses wdiff together with the pager more, as in:

wdiff -t old_file new_file | more

However, some versions of more use termcap emphasis for their own purposes, so strange interactions are possible.

−−start−delete argument

Has the same effect as −w.

−w argument

Use argument as the "start delete" string. This string will be output prior to every sequence of deleted text, to mark where it starts. By default, no start delete string is used unless there is no other means of distinguishing where such text starts; in this case the default start delete string is [−.

−−end−delete argument

Has the same effect as −x.

−x argument

Use argument as the "end delete" string. This string will be output after every sequence of deleted text, to mark where it ends. By default, no end delete string is used unless there is no other means of distinguishing where such text ends; in this case the default end delete string is −].

−−start−insert argument

Has the same effect as −y.

−y argument

Use argument as the "start insert" string. This string will be output prior to any sequence of inserted text, to mark where it starts. By default, no start insert string is used unless there is no other means of distinguishing where such text starts; in this case the default start insert string is {+.

−−end−insert argument

Has the same effect as −z.

−z argument

Use argument as the "end insert" string. This string will be output after any sequence of inserted text, to mark where it ends. By default, no end insert string is used unless there is no other means of distinguishing where such text ends; in this case the default end insert string is +}.

−−avoid−wraps

Has the same effect as −n.

−n

Avoid spanning the end of line while showing deleted or inserted text. Any single fragment of deleted or inserted text spanning many lines will be considered as being made up of many smaller fragments not containing a newline. So deleted text, for example, will have an end delete string at the end of each line, just before the new line, and a start delete string at the beginning of the next line. A long paragraph of inserted text will have each line bracketed between start insert and end insert strings. This behaviour is not selected by default.

Note that options −p, −t, and −[wxyz] are not mutually exclusive. If you use a combination of them, you will merely accumulate the effect of each. Option −l is a variant of option −p.

EXAMPLES

The following command produces a copy of new_file, shifted right one space to accommodate change bars since the last revision, ignoring those changes coming only from paragraph refilling. Any line with new or changed text will get a | in column 1. However, deleted text is not shown nor marked.

wdiff -1n old_file new_file | sed -e ’s/^/ /;/{+/s/^ /|/;s/{+//g;s/+}//g’

BUGS

If you find a bug in wdiff, please send electronic mail to pinard AT iro DOT umontreal DOT ca. Include the version number, which you can find by running wdiff −−version. Include in your message sufficient input to reproduce the problem and also, the output you expected.

wdiff currently calls diff. wdiff would be quicker and cleaner to implement if it were part of the diff suite of programs.

Here are some (un-processed) suggestions:

Make an MS-DOS port.

Select by options exactly what is whitespace.

Have a wpatch program. Hard to see a good way of doing this.

IDENTIFICATION

Author: Francois Pinard, pinard AT iro DOT umontreal DOT ca
Manual Page: Colin M. Brough, cmb AT epcc DOT ed DOT ac DOT uk
Revision Number: 0.4; Release Date: 1992/12/21.

SEE ALSO

diff(1), less(1), cat(1), more(1), termcap(3).

pdf