Finding Differences in Files with sdiff


Finding Differences in Files with sdiff

Yet another way to compare files is to use sdiff, which presents the two files onscreen so that you can visually compare them (see Code Listing 6.16).

Code Listing 6.16. sdiff puts the files side by side, so you can easily see the differences.

[ejr@hobbes manipulate]$ sdiff dearliza   dearhenry July 25, 1998   July 25, 1998 Dear Liza,    | Dear Henry, There's a hole in my bucket, dear  Lisa dear Liza. | Please fix it dear Henry,            dear Henry. Yours,     Yours, Henry      | Liza      | PS,you for got your tool box last time. [ejr@hobbes manipulate]$ 

To Compare Files with sdiff:

  • sdiff dearliza dearhenry

    At the shell prompt, type sdiff and the filenames to compare the two files. The output, as shown in Code Listing 6.16, presents each line of the two files side by side, separating them with

    • (Nothing) if the lines are identical

    • < if the line exists only in the first file

    • > if the line exists only in the second file

    • | if they are different

Tips

  • If most of the lines are the same, consider using the -s flag so the identical lines are not shown. For example, type sdiff -s dearliza dearhenry

  • If the output scoots by too fast to read, remember that you can pipe the entire command to more, as in sdiff dearliza dearhenry | more





Unix(c) Visual Quickstart Guide
UNIX, Third Edition
ISBN: 0321442458
EAN: 2147483647
Year: 2006
Pages: 251

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net