or drop the sort and diff and use comm with -1, -2, -3 to get the master unique, slave unique and unions. | [reply] [Watch: Dir/Any] |
or drop the sort and diff and use comm
Agreed; comm rocks. You can't drop the sort, however, as comm expects sorted input.
Update: I expect you know this as I just noticed you explicitly mentioned pre-sorted lists elsewhere in this thread. I suppose it is worth repeating here anyway though.
-sauoq
"My two cents aren't worth a dime.";
| [reply] [Watch: Dir/Any] |
hossman,
I probably should have mentioned that I thought of that immediately. The problem is that I wasn't sure diff was perfect, and I didn't have time to find out. I figured it was possible, even sorted, for the same filename to be several hundereds of lines away from one another depending on how divergent the two servers were.
If the administrator that made this request hasn't already taken steps to modify the two systems, I will compare the results of my script against what diff says to see. I just thought diff assumed a certain amount of similarity and gave up if the lines were too far apart.
Cheers - L~R
Update: After googling a bit, I found enough to convince me that diff would not have worked | [reply] [Watch: Dir/Any] |
comm -2 -3 master slave >unique_to_master
comm -1 -3 master slave >unique_to_slave
comm -1 -2 master slave >union_master_slave
| [reply] [Watch: Dir/Any] [d/l] |
waswas-fng,
Cool! I am not sure how I missed this. So as long as both files are sorted, comm will be 100% correct no matter how divergent the two servers are?
I will have to try it.
Cheers - L~R
| [reply] [Watch: Dir/Any] |
comm -1 -2 master slave >intersection_master_slave
| [reply] [Watch: Dir/Any] [d/l] |
Recursively diffing all of the acctual files on each box probably wouldn't have been a good idea, but i've never had a problem diffing sorted lists -- no matter how much difference there is. (I'm curious as to exactly what you found with google convinced you diff would have been bad)
As many people have allready pointed out, "comm" works just as well (if not better) then diff ... i just tend to dislike the whole "tabed" output of comm ... but "comm -1" followed by "comm -2" would be great if you didn't mind having two seperate lists.
| [reply] [Watch: Dir/Any] |