Automatic Diff -q Between Two Directories

Discussion in 'Ruby' started by Frederick Lee, Sep 8, 2010.

  1. Greetings:
    I've been toying with ruby off/on in years. Now I've come across a
    practical application that ruby may be of use to me.

    Scenario: Two directories with many files in parallel: differences is
    content, names are same.

    I need to check which files have been modified.
    That is, automating the $diff -q command thusly:

    [/Users/admin/workarea]diff -q file1.txt file2.txt >> result.txt
    [/Users/admin/workarea]diff -q file3.txt file4.txt >> result.txt
    ...

    [/Users/admin/workarea]more result.txt
    Files file1.txt and file2.txt differ
    Files file3.txt and file4.txt differ
    ...

    So imaging the scenario:
    /src1
    /src1/file1.txt
    /src1/file2.txt
    ...

    vs.

    /src2
    /src2/file1.txt
    /src2/file2.txt
    ...

    So essentially there's a loop through one directory vs a parallel
    directory.
    Is there simple example how I could do this in (interactive/irb) Ruby?

    Regards,
    Ric.
    --
    Posted via http://www.ruby-forum.com/.
     
    Frederick Lee, Sep 8, 2010
    #1
    1. Advertising

  2. Frederick Lee

    Ryan Davis Guest

    On Sep 8, 2010, at 10:59 , Frederick Lee wrote:

    > Scenario: Two directories with many files in parallel: differences is
    > content, names are same.


    % man diff
    ...
    -r --recursive
    Recursively compare any subdirectories found.
    ...
     
    Ryan Davis, Sep 8, 2010
    #2
    1. Advertising

  3. Ryan Davis wrote:
    > On Sep 8, 2010, at 10:59 , Frederick Lee wrote:
    >
    >> Scenario: Two directories with many files in parallel: differences is
    >> content, names are same.

    >
    > % man diff
    > ...
    > -r --recursive
    > Recursively compare any subdirectories found.
    > ...



    Did the man diff -rq /dir1 /dir2 > result.txt

    Works great!
    So simple, so useful.
    Thanks!
    --
    Posted via http://www.ruby-forum.com/.
     
    Frederick Lee, Sep 9, 2010
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Cyril Vi?ville

    diff Process under diff users

    Cyril Vi?ville, Jun 29, 2004, in forum: Perl
    Replies:
    1
    Views:
    527
    Joe Smith
    Jun 29, 2004
  2. Berrucho
    Replies:
    2
    Views:
    672
    Infant Newbie
    Dec 5, 2003
  3. A Traveler

    Diff CSS styles for diff INPUT TYPE='s?

    A Traveler, Aug 31, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    4,969
    Steve Fulton
    Aug 31, 2004
  4. Santa
    Replies:
    1
    Views:
    1,153
    Mark A. Odell
    Jul 17, 2003
  5. Austin Ziegler

    [ANN] Diff::LCS 1.1.0, Diff::LCS 1.0.4

    Austin Ziegler, Aug 8, 2004, in forum: Ruby
    Replies:
    3
    Views:
    209
    Austin Ziegler
    Aug 9, 2004
Loading...

Share This Page