Output only changed lines

49 Views Asked by At

I'm trying to get diff to only output changed lines, not added or deleted files.

So if file 1 contains:

hello 1
my 2
name 3

and file 2 contains:

hello 2
my 2
earth

I would get output similar to:

< hello 1
> hello 2

I've searched both on Google and Stack Overflow, and found a perl script at Stack Overflow, but that doesn't output anything.

Any way this can easily be done?

1

There are 1 best solutions below

0
On

According to your example, I guess your question is "get diff to only output changed lines, not added or deleted lines." (not files). Right ?

If so, I think it's difficult to distinguish "added or deleted lines" from "changed lines".

e.g.

line 1
line 2
line 3

vs

line 1
line 2
lane 3

The differences of the 3rd line, is a "changed" or a "added or deleted"