Linux – formatting of the diff output

diff()linuxshell

I have 2 files that I want to differ. File B is produced appending some new line to file A.
I want to highlight the appended data by using diff.

I would like to avoid printing out the '>' characters and the '10a11,14' of the output below.

Reading the man pages of diff I can see that you can specify the formatting of the result ( LFMT ) but I am struggling in producing something useful.

Could you help in removing those characters I don't need?

Regards

AFG

   diff --left-column A.txt  B.txt

   10a11,14
   > TXT :   some text
   >         some text
   >         some text
   >         some text

Best Answer

There are two easy ways of doing this, you can either parse the output of diff or you can use comm.

  • diff fileA fileB | grep '>' | sed 's/> *//'

  • comm -13 fileA fileB

Related Question