Next: diff
Performance Tradeoffs, Previous: Comparing Directories, Up: Comparing and Merging Files [Contents][Index]
diff
Output Prettierdiff
provides several ways to adjust the appearance of its output.
These adjustments can be applied to any output format.
Next: Omitting trailing blanks, Up: Making diff
Output Prettier [Contents][Index]
The lines of text in some of the diff
output formats are
preceded by one or two characters that indicate whether the text is
inserted, deleted, or changed. The addition of those characters can
cause tabs to move to the next tab stop, throwing off the alignment of
columns in the line. GNU diff
provides two ways
to make tab-aligned columns line up correctly.
The first way is to have diff
convert all tabs into the correct
number of spaces before outputting them; select this method with the
--expand-tabs (-t) option. To use this form of output with
patch
, you must give patch
the -l or
--ignore-white-space option (see Applying Patches with Changed White Space, for more
information). diff
normally assumes that tab stops are set
every 8 print columns, but this can be altered by the
--tabsize=columns option.
The other method for making tabs line up correctly is to add a tab character instead of a space after the indicator character at the beginning of the line. This ensures that all following tab characters are in the same position relative to tab stops that they were in the original files, so that the output is aligned correctly. Its disadvantage is that it can make long lines too long to fit on one line of the screen or the paper. It also does not work with the unified output format, which does not have a space character after the change type indicator character. Select this method with the -T or --initial-tab option.
Next: Paginating diff
Output, Previous: Preserving Tab Stop Alignment, Up: Making diff
Output Prettier [Contents][Index]
When outputting lines in normal or context format, or outputting an
unchanged line in unified format, diff
normally outputs a
blank just before each line. If the line is empty, the output of
diff
therefore contains trailing blanks even though the
input does not contain them. For example, when outputting an
unchanged empty line in context format, diff
normally
outputs a line with two leading spaces.
Some text editors and email agents routinely delete trailing blanks,
so it can be a problem to deal with diff output files that contain
them. You can avoid this problem with the
--suppress-blank-empty option. It causes diff
to
omit trailing blanks at the end of output lines in normal, context,
and unified format, unless the trailing blanks were already present in
the input. This changes the output format slightly, so that output
lines are guaranteed to never end in a blank unless an input line ends
in a blank. This format is less likely to be munged by text editors
or by transmission via email. It is accepted by GNU
patch
as well.
Previous: Omitting trailing blanks, Up: Making diff
Output Prettier [Contents][Index]
diff
OutputIt can be convenient to have long output page-numbered and time-stamped.
The --paginate (-l) option does this by sending the
diff
output through the pr
program. Here is what the page
header might look like for ‘diff -lc lao tzu’:
2002-02-22 14:20 diff -lc lao tzu Page 1
Next: diff
Performance Tradeoffs, Previous: Comparing Directories, Up: Comparing and Merging Files [Contents][Index]