Johnny
Johnny

Reputation: 53

Unix Get only Difference between 2 files

Hello i am trying to compare the files inside 2 directories and output all the new lines, but i am getting the new lines.

My question is how to output each file difference to a separates file not all on the same output. Thank you

Here is the Command:

[root@ links]# diff -r directory1/ directory2/

Here is the output :

diff -bur directory1/file1 directory2/file1
--- directory1/file1    2016-11-16 07:10:48.646726219 -0500
+++ directory2/file1    2016-11-16 07:11:02.358639590 -0500
@@ -3,3 +3,8 @@
+6
+7
+8
+9
+10
diff -bur directory1/info1 directory2/info1
--- directory1/info1    2016-11-16 07:04:35.496097219 -0500
+++ directory2/info1    2016-11-16 07:05:19.840813752 -0500
@@ -1,3 +1,8 @@
+d
+e
+f
+g
+h

What i need is each difference on a separate output file like this:

output 1

diff -bur directory1/file1 directory2/file1
--- directory1/file1    2016-11-16 07:10:48.646726219 -0500
+++ directory2/file1    2016-11-16 07:11:02.358639590 -0500
@@ -3,3 +3,8 @@
+6
+7
+8
+9
+10

output2

diff -bur directory1/info1 directory2/info1
--- directory1/info1    2016-11-16 07:04:35.496097219 -0500
+++ directory2/info1    2016-11-16 07:05:19.840813752 -0500
@@ -1,3 +1,8 @@
+d
+e
+f
+g
+h

Upvotes: 0

Views: 132

Answers (1)

Sean83
Sean83

Reputation: 493

I believe you cannot do that using diff.

However, you can by alternative tools in Linux.
For example, vimdiff which gives you seperated page that you prefer and there are other tools like kompare and diffMerge. Please refer to this link. HERE

Upvotes: 1

Related Questions