Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

format output from diff utility 2

Status
Not open for further replies.

unixwhoopie

Programmer
May 6, 2003
45
0
0
US
The output generated from diff is not easy to understand for a common user. what is the quickest way to format it so the user will be able to understand?

I am comparing 2 db schemas and printing the table info using diff.

Thanks
 
Try using [tt]sdiff[/tt]. That prints the differences side by side in a more human readable format.
 
When you do use sdiff, you may need/want to use the -w switch to match the width of your output medium so that you are not wrapping the output creating more difficult to read results.

Also the -s switch is useful for suppressing identical lines, if you just want to concentrate on the differences.

man sdiff

Code what you mean,
and mean what you code!
But by all means post your code!

Razalas
 
sdiff is in a much better format. However I see one problem.

file 1 file 2
____________________
A A
B C
C D
D

when I compare file 1 and 2, file 2 is only missing line B.
But sdiff compares line by line and the output shows as 2 lines that are different and 1 line that is missing. Is there any workaround for this?

Thanks
 
My sdiff output with your posted samples:
A A
B <
C C
D D

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I probably need to reformat my question. It is not as straight forward as I indicated.

file 1 file 2
_________________________
A (hi) A (hi)
B C (bad)
C (good) D (good)
D (good)

In this case A and D match. B is missing in file 2 and C does not match. However, when I run sdiff, the output is shown as follows:

s2,3c2
B | C (bad)
C(good) <

How can I get the output in such a way that it displays B as missing and compares C.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top