1

I have 2 files for which i want to diff side by side using the following command with the line numbers:

diff -y abc1.txt abc2.txt

The above command just prints the side by side diff but doesn't display the line numbers associated with the files.

I even tried:

diff -y --unchanged-line-format="" --new-line-format=":%dn: %L" abc1.txt abc2.txt

But it gives some format conflict exception. Is there any way to do it ? I have searched a lot but couldn't find any solutions for it. I can't use third party tools just for your information. Any brilliant ideas are highly appreciated.

NOTE:

I want the file numbers present of the file itself and not the line numbers generated by piping to cat -n etc.. Lets say, i am doing diff using "--suppress-common-l‌​ines" then the line numbers should be omitted which are not shown in the diff. I want to display the line numbers associated with the files. I don't want to generate line numbers in my diff output

Ronit Mishra
  • 105
  • 11
  • did you try leaving out `--unchanged-line-format=""` ? Good luck. – shellter Aug 20 '16 at 17:31
  • I think you are looking for `--line-format=LFMT` (applies to all input lines) instead of `--new-line-format=` (applies to just the `new` file) as I read it. – David C. Rankin Aug 20 '16 at 20:41
  • 2
    Do you mean something like `diff <(cat -n abc1.txt) <(cat -n abc2.txt)` ? – Walter A Aug 20 '16 at 22:09
  • Superb Walter ! I think you gave the correct answer but what if we are doing a recursive diff between folders in that case how to deal with it ? For example: For the scenario, diff -ry folder1 folder2 – Ronit Mishra Aug 21 '16 at 06:34

0 Answers0