L.V.Gandhi wrote:
I have two directories A and B. In each directory, I have nearly 1000
files with same names. I would like to compare both directories and find
out which files differ more than say 5 lines. I use kompare and see
manually. How to do it in command line easily?
--
L.V.Gandhi
http://lvgandhi.tripod.com/
linux user No.205042
Try these diff commands. The verbosity is greater in the ones with the "u"
option.
==================================
First, some sample files are
created in directories A and B,
these files are identical.
==================================
Wed Jun 13 15:01:18 ([EMAIL PROTECTED]) ~/difftest>find
.
./A
./A/one
./A/three
./A/two
./B
./B/one
./B/three
./B/two
==================================
By default, the diff command does
not report anything if the files
are identical.
The "r" option is needed to have
diff recurse into the A and B
directories.
==================================
Wed Jun 13 15:01:22 ([EMAIL PROTECTED]) ~/difftest>diff -r A B
==================================
Add the "s" argument to show when
files are the same.
==================================
Wed Jun 13 15:01:25 ([EMAIL PROTECTED]) ~/difftest>diff -rs A B
Files A/one and B/one are identical
Files A/three and B/three are identical
Files A/two and B/two are identical
==================================
Let's change the B/two file to see
how diff reports the change.
==================================
Wed Jun 13 15:01:29 ([EMAIL PROTECTED]) ~/difftest>echo "this one is
different" > B/two
==================================
Omit the "s" option if you want to
see only files that have changed.
==================================
Wed Jun 13 15:02:02 ([EMAIL PROTECTED]) ~/difftest>diff -rs A B
Files A/one and B/one are identical
Files A/three and B/three are identical
diff -rs A/two B/two
1c1
< two
---
> this one is different
==================================
The "u" option (unified diff)
displays more information
==================================
Wed Jun 13 15:02:06 ([EMAIL PROTECTED]) ~/difftest>diff -ru A B
diff -ru A/two B/two
--- A/two 2007-06-13 15:01:18.000000000 -0600
+++ B/two 2007-06-13 15:02:02.000000000 -0600
@@ -1 +1 @@
-two
+this one is different
==================================
To show only the filenames,
modify the B/three file.
==================================
Wed Jun 13 15:09:20 ([EMAIL PROTECTED]) ~/difftest>echo "zzzzzzzz" > B/three
==================================
Run the diff command and grep for
"diff" at the start of the line.
This will show only the filenames
that differ.
==================================
Wed Jun 13 15:09:31 ([EMAIL PROTECTED]) ~/difftest>diff -r A B | grep
"^diff"
diff -r A/three B/three
diff -r A/two B/two
Hope this is helpful.
========Keith
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]