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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prob in file comparison

Status
Not open for further replies.

nithink

Programmer
Nov 7, 2002
92
US
hi,.. i know this question is too lengthy... but pls bear with me...
i need to compare 2 files and print the diff in another file... the 2 files look like these....

file 1 file 2

xyz_20021204_0000.txt xyz_20021204_0100.txt
xyz_20021204_0015.txt xyz_20021204_0115.txt
xyz_20021204_0030.txt xyz_20021204_0130.txt
xyz_20021204_0045.txt xyz_20021204_0145.txt
xyz_20021204_0100.txt xyz_20021204_0200.txt
xyz_20021204_0115.txt xyz_20021204_0000.txt
xyz_20021204_0130.txt xyz_20021204_0015.txt
xyz_20021204_0145.txt xyz_20021204_0030.txt
xyz_20021204_0200.txt xyz_20021204_0045.txt
xyz_20021204_0215.txt


for getting the diff, I use sdiff like this...

sdiff -s ./file1 ./file2 | awk -F_ '{if ($1 ~ /xyz/) print $0}' | awk '{print "get " $1}' > ./tmp4

so the output i expect is like this

get xyz_20021204_0215_Q.txt

'coz this is the only diff between the 2 files.. but i'm getting something like this,

get xyz_20021204_0000_Q.txt
get xyz_20021204_0015_Q.txt
get xyz_20021204_0030_Q.txt
get xyz_20021204_0045_Q.txt
get >
get >
get >
get >
get >

can u pls help me out in this... ur help appreciated....
thx in advance...

 
Sorry, not much time, but have you considered comm for this? - do a man comm

Cheers.
 
Ken. thx for ur suggestion.. i'll try that too.. trying to get this script work from y'day.. still no joy...
 
hi.. couldnt figure out how to solve this.. can anyone help out ? is there anyother way ? appreciate ur help...
 
Not sure if this will help much, but I noticed that the files side by side were not matched up correctly. Did you run a sort on each file before doing the sdiff?
 
Hi pmcmicha, i didnt sort before sdiff.. i'll try that and let yu know.. thx for ur suggestion..

 
Thx pmcmicha & KenCunningham... it worked... i sorted and then did a "comm"....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top