How to display line numbers in side by side diff of folders in unix?

301 Views Asked by At

I want to display line numbers associated to the files in a recursive side by side diff between two directories. To display line numbers of files in a diff, the command i use is:

diff -y <(cat -n abc1.txt) <(cat -n abc2.txt)

But in case of directories, how to do it ?

diff -y folder1 folder2

The expected output is:

folder1/file1a.txt      folder2/file2a.txt
                           >  1 
1 This is original content |  2 This is changed content

folder1/file1b.txt      folder2/file2b.txt
                                   >  1
                                   >  2
1 This is another original content |  3 This is another changed content 2

Is there any solution like using xargs or something as what I have observed is that the recursive diff actually does diff on each file in the directories, so is there anyway to append the line numbers at granular level using xargs before the diff executes the command for a particular file ? Any brilliant idea from anyone ?

NOTE:

I don't want to generate line numbers i want to display line numbers associated with the files of the folders.

0

There are 0 best solutions below