PDA

View Full Version : Help with diff



HLEBARKATA
January 1st, 2009, 05:24 PM
Hi all,
I try with diff to compare 2 text files, but I want only to
get the exact output.
I mean like
file 1:

Hello
World
How
Are
You

file 2:
Hello
How
Are
You

diff file1 file2 to have the output "World"

Thanks for any help

ghostdog74
January 1st, 2009, 06:34 PM
check the diff man page whether there are options for output formatting, otherwise, just simply


diff file1 file2 | awk '/^</{$1="";print}'

HLEBARKATA
January 1st, 2009, 07:06 PM
The first thing I did was to have a look at the man page but this option
doesnt exists or I havent seen it.
diff file1 file2 | awk '/^</{$1="";print}'
removes all new lines and dont work (More than half of the differences dont show up)

ghostdog74
January 2nd, 2009, 01:32 AM
show a sample of what the diff output is, and then how you want it to look like.