Automatic Diff -q Between Two Directories

F

Frederick Lee

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.
 
R

Ryan Davis

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

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

Frederick Lee

Ryan said:
% 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!
 

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top