home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 28.14 Even More Uses for make Chapter 28
Comparing Files
Next: 29. Spell Checking, Word Counting, and Textual Analysis
 

28.15 Show Changes in a troff File with diffmk

Whenever you produce multiple drafts of a document for review, "change marks" in the newer draft are useful for showing where additions and deletions have occurred. The troff (43.13 ) request .mc (margin character) can be used to print change marks in the margin of any document that is formatted through troff , and the UNIX command diffmk uses .mc requests to produce marked drafts. diffmk has the following syntax:

% diffmk version.1 version.2 marked_file

The above command line compares an old version of a file (version.1 ) to a new version (version.2 ) and creates a third file, marked_file . marked_file consists of the contents of version.2 plus .mc requests that show where that file differs from version.1 . When marked_file is formatted, additions and changes will be indicated by vertical bars (| ) in the margin, while deleted text will be indicated by an asterisk (* ) in the margin.

There are times when you'll want the diffmk command to run on many files at once. For example, suppose you have a project directory containing eight chapter files from a first draft:

% ls project


chapters.old/          stuff
% ls project/chapters.old


ch01     ch03     ch05     ch07
ch02     ch04     ch06     ch08

Before making second-draft revisions, you copy the chapter files into a directory named chapters.new :

% ls project


chapters.new/          chapters.old/          stuff
% cd project/chapters.new


% ls


ch01     ch03     ch05     ch07
ch02     ch04     ch06     ch08

Copying the files allows you to edit new versions while preserving the original files in the old directory. After you've edited the files in the new directory, you want to run diffmk on all of them. In the new directory, you would want to type:

% diffmk  ../chapters.old/ch01  ch01  ch01.diffmk


% diffmk  ../chapters.old/ch02  ch02  ch02.diffmk


% diffmk  ../chapters.old/ch03  ch03  ch03.diffmk


   ...

A shell loop (9.11 , 9.12 ) would simplify the amount of typing you need to do. You can save disk space by using a version control utility such as SCCS or RCS (20.12 ) .

- DG


Previous: 28.14 Even More Uses for make UNIX Power Tools Next: 29. Spell Checking, Word Counting, and Textual Analysis
28.14 Even More Uses for make Book Index 29. Spell Checking, Word Counting, and Textual Analysis

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System