Go to the first, previous, next, last section, table of contents.


Making @command{diff} Output Prettier

@command{diff} provides several ways to adjust the appearance of its output. These adjustments can be applied to any output format.

Preserving Tab Stop Alignment

The lines of text in some of the @command{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 @command{diff} provides two ways to make tab-aligned columns line up correctly.

The first way is to have @command{diff} convert all tabs into the correct number of spaces before outputting them; select this method with the @option{-t} or @option{--expand-tabs} option. @command{diff} assumes that tab stops are set every 8 print columns. To use this form of output with @command{patch}, you must give @command{patch} the @option{-l} or @option{--ignore-white-space} option (see section Applying Patches with Changed White Space, for more information).

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 @option{-T} or @option{--initial-tab} option.

Paginating @command{diff} Output

It can be convenient to have long output page-numbered and time-stamped. The @option{-l} and @option{--paginate} options do this by sending the @command{diff} output through the @command{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


Go to the first, previous, next, last section, table of contents.