0

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
Johnny
  • 53
  • 1
  • 9
  • Why don't you do `diff -bur directory1/ directory2/ > output_file`, if you want this output to be written to a file? Your question is unclear to me. How many files are there in each directory? How many output files do you want? – Am_I_Helpful Nov 16 '16 at 12:37
  • i did but will output all to the same output, if i have 2 files being compared i need 2 outputs ... each difference on a seperate output file – Johnny Nov 16 '16 at 12:43
  • your question is not very clear. How do you want your two files look like? – Sean83 Nov 16 '16 at 12:45
  • i just updated the question now is clearer please have a look @Sean83 – Johnny Nov 16 '16 at 12:47
  • No the diff is mart enough to only compare files with the same filename @Am_I_Helpful – Johnny Nov 16 '16 at 13:18
  • @Johnny Updated – Sean83 Nov 16 '16 at 13:34

1 Answers1

1

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

Sean83
  • 493
  • 4
  • 14