The output is actually a description of how to transform the old file into the new one. Here, diff is telling you three things:
· !SPAN>The fifth line of the file has undergone a change. The 5c5 message says to replace line 5 of the old file with line 5 of the new file. Both the old and new text are displayed, separated by a line of three dashes. (The less-than (<) notation means "remove this line," and the greater-than (>) sign means "add this line.")
· !SPAN>Line 7 of the old file does not appear in the new file. The 7d6 message says to delete line 7 from the old file, and the files will then be in sync, starting at line 6 of the new file. The text to be deleted is displayed on the next line.
· !SPAN>A line was added to the new file. The 21a22 message says to add a new line after line 21 of the old file. The text to be added is displayed on the final line of the output.
Two useful flags you can specify when comparing files are !SPAN>-b (ignore blanks) and !SPAN>-i (ignore case). You can use them separately or in combination. The ignore blanks feature is especially useful when you're comparing the source code for two programs, since indentation changes are rarely significant. For example, here's how you might compare two program files, !SPAN>ur2cool.c and !SPAN>ur2cool.backup:!SPAN>
diff -b -i ur2cool.c ur2cool.backup!SPAN>
Don't worry if you have some difficulty understanding the output of the !SPAN>diff command. It's c ryptic because it was designed to be used by computers, not humans. (Some source-code control systems used by programmers use !SPAN>diff to keep a record of the changes made to a program over time.)!SPAN>
Do pay attention, though, to the less-than and greater-than indicators to see at a glance what was added or deleted; and be happy if you manage to get a general feeling for the ways the files differ.!SPAN>
For more information on the diff command, see the diff manual.
Previous Lesson: Searching for Files
Next Lesson: Task Scheduling
|
![]() |
|
| <Send This Link to a Friend> <Help> <Bookmark This Page> | ||