Hi All,

I am trying to compare two folder using "cmp" command.

Folder1=/path/to/folder1
Folder2=/path/to/folder2

Folder1 has file name
abc.txt
efg.txt
hij.txt
.
.
.
.....................
xyz.txt

Folder2 has file name
abc.txt
efg.txt
.
.
.
.....................
xyz.txt


I want to compare this two folder with similar name.
Means Folder1/abc.txt should be comapred with Folder1/abc.txt

similarly

Folder1/xyz.txt should be comapred with Folder1/xyz.txt

The difference should be dump in any file.

Recommended Answers

All 2 Replies

The 'comm' command allows you to find out
- lines only on the left
- lines only on the right
- lines common

Use this to extract a list of files which are common to both directories.

Hey There,

You can also use "diff -r -y" if your version of diff supports it. This will give you output like:

$ ls a b
a:
a b c

b:
a a.gz b b.gz c.gz

$ diff -y -r a b
diff -y -r a/a b/a
Only in b: a.gz
diff -y -r a/b b/b
Only in b: b.gz
Only in a: c
Only in b: c.gz

Just another option if you can use it :)

Best wishes,

Mike

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.