0

How to find diff of two files but only show lines which have common starting string?

For example, file1:

start1 1234
1234
start2 1234

file2:

start1 ABCD
ABCD
start2 ABCD

And the diff should be just:

> start1 1234
---
< start1 ABCD
> start2 1234
----
< start2 ABCD

or something like this:

start1
start2

1 Answers1

0

You would need to script/code it yourself, because a classic diff (or git diff --no-index which can be used with any two files outside of any Git repository) would display only hunks.

See "In the context of git (and diff), what is a “hunk”": that would display more than just the different lines.

diff finds sequences of lines common to both files, interspersed with groups of differing lines called hunks.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250