2

I have 61 files (files names are like cutpathid-hca.txt, cutpathid-hey.txt, cutpathid-hpl.txt, cutpathid-hpyd.txt, cutpathid-hpz.txt), each comprises of the list like below, I want to compare them and print similarity and difference in each file with its file name.

00010
00020
00030
00040
00051
00052
00500
00520
00620
00630
00640
00650
00190
00680
00910
00920
00061
00071
00072
00121
00561
00564
00565
00592
01040
00230
00240
00250
00260
00270
00280
00290
00300
00310

OUTPUT shoud look like

Similar lines in cutpathid-hca.txt, cutpathid-hey.txt, cutpathid-hpl.txt, cutpathid-hpyd.txt, cutpathid-hpz.txt

00010
00020
00030
00040
00051
00052
00500
00520
00620
00630
00640
00650
00190
00680
00910
00920
00061
00071
00072
00121

Unique lines in cutpathid-hca.txt

00240 00250 00260

unique lines in cutpathid-hpl.txt

00290 00300

unique lines in cutpathid-hpz.txt

00051 00052

  • Do you want to do a pairwise comparison between all files? What should the output look like? – Kusalananda Sep 4 '18 at 11:35
  • Each of the 61 files has 34 lines, and you want to know which files have the same or different contents of each of those lines? Or can you clarify what "similar" and "different" mean to you? – Jeff Schaller Sep 4 '18 at 11:36
  • @JeffSchaller Each of the 61 files has more than 1500 lines and yes i want to know which files have the same or different contents of each of those lines. – waqar Sep 4 '18 at 11:44
  • do they all have the same number of lines? – Jeff Schaller Sep 4 '18 at 11:45
  • @JeffSchaller yes almost some files may have a difference of 5 to 10 lines. – waqar Sep 4 '18 at 12:20
0

Sadly, standard diff supports only two files at a time.

You can easily install Diffuse (it's a python program so it should work on every "recent" linux/bsd/*nix distribution) which looks like it can diff more than 2 files at a time.

Edit as per comment

Actually, Diffuse is a GUI program. I've just installed it ad made a quick test with 3 files.

Command was:

diffuse /tmp/file_1.txt /tmp/file_2.txt /tmp/file_3.txt

and results as in this screenshot:

Diffuse output

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.