Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Balancing Coding Time And Code Quality

by hossman (Prior)
on Dec 04, 2003 at 00:08 UTC ( [id://312056]=note: print w/replies, xml ) Need Help??


in reply to Balancing Coding Time And Code Quality

What would you have come up with in the same circumstances?
% ssh master 'find /' | sort > /tmp/master % ssh slave 'find /' | sort > /tmp/slave % diff /tmp/master /tmp/slave

Replies are listed 'Best First'.
Re: Re: Balancing Coding Time And Code Quality
by waswas-fng (Curate) on Dec 04, 2003 at 00:25 UTC
    or drop the sort and diff and use comm with -1, -2, -3 to get the master unique, slave unique and unions.


    -Waswas
      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.";
      
Re: Re: Balancing Coding Time And Code Quality
by Limbic~Region (Chancellor) on Dec 04, 2003 at 00:34 UTC
    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

      man comm

      comm -2 -3 master slave >unique_to_master comm -1 -3 master slave >unique_to_slave comm -1 -2 master slave >union_master_slave


      -Waswas
        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

        Nice, thanks!

        But isn't the 3rd line be the intersection and not the union?

        comm -1 -2 master slave >intersection_master_slave

        Mike

      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://312056]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-03-28 08:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found