I want to compare lines in two files, but to minimize noise in the output, I want only the actual differences in the lines to be printed.
For instance, given the two files below:
a.txt
a b c d e f g h i j k l m n o p q r s t u v w x y z
b.txt
a B c d e f g h i j k l m n o p q r s t u v w x y z
(the difference between them is the case of letter b
)
I want the output to be something like:
[-b-]{+B+}
Currently, the best approach I found was to use git diff --word-diff
, but it outputs the whole line:
a [-b-]{+B+} c d e f g h i j k l m n o p q r s t u v w x y z
Is there a more direct way to do it, other than manually parsing the output? Also, ideally I would prefer to use something more commonly available than git diff
, e.g. a POSIX shell tool that would not require the user to install extra packages.
b
andB
so it's obvious? I understand that this was probably the actual difference, but for purposes of the question you can make it easier. – Barmar Jan 18 '19 at 18:02