Previous topic |
Next topic |
Contents |
Contact z/OS |
Library |
PDF
Comparing files z/OS UNIX System Services User's Guide SA23-2279-00 |
|
Consider the following situation: A warehouse has an active file that keeps track of current inventory. As goods are brought in, appropriate records are added to the file. As orders are shipped out, the records are deleted. At the end of the day, the warehouse makes a copy of the active file to keep as a permanent journal. It would be useful for such a business to be able to compare one
day's journal to another day's to see what has changed. This can be
done with the diff command:
compares
the two files. The output of diff shows
lines that are in one file but not in the other. The lines in oldfile but
not in newfile are displayed with a < in
front of them. Lines in newfile but not in oldfile are
displayed with > in front.For example, say you have a file wmnhist.text with one line
in it:
Then
you created a copy of the file with the command:
You
use an editor—either the ISPF editor or the ed text
editor—to change the first line in newhist.text to:
You
save the file. Now you enter the command:
diff displays:
The 1c1 at the beginning of the diff output indicates that line 1 in the old file has changed (c) when compared with line 1 in the new file. diff shows what must be changed in the first file to make it look like the second file. Remember this sequence when you look at the output of diff. Here the first file, wmnhist.txt, contained the line Susan B. Anthony awoke one morning where the second file, newhist.txt, has Sojourner Truth awoke one morning. New lines are indicated with an a (add lines), and lines that should be deleted are indicated with a d (delete). See the diff command description in z/OS UNIX System Services Command Reference for more details. diff helps you determine what has changed in the time that elapsed between saving the two files. The same sort of operation is useful in many record-keeping situations, any time you have two different versions of the same file and you want to check the differences. |
Copyright IBM Corporation 1990, 2014
|