How does `diff` decide whether a difference is change (i.e. replacement) or combination of addition and deletion?
Clash Royale CLAN TAG#URR8PPP
up vote
-3
down vote
favorite
I was wondering how diff
decides whether a difference is change (i.e. replacement) or combination of addition and deletion?
The best I can find from diffutils' manual is
‘fct’
Replace the lines in range f of the first file with lines in range t
of the second file. This is like a combined add and delete, but more
compact. For example, ‘5,7c8,10’ means change lines 5–7 of file 1 to
read as lines 8–10 of file 2; or,if changing file 2 into file 1,
change lines 8–10 of file 2 to read as lines 5–7 of file
1.
For example, I have two files, each having four lines
$ paste f2 f3
0 1
1 2
3 3
5 6
and I diff them
$ diff f2 f3
1d0
< 0
2a2
> 2
4c4
< 5
---
> 6
Why is
1d0
< 0
2a2
> 2
not
1,2c1,2
< 0
< 1
---
> 1
> 2
instead?
The alternative I gave and the diff
output both have 3
as the common line, but my alternative treats the different lines before the common line as c
i.e. replacement, while the diff
output treats them as a combination of deletion and addition.
text-processing diff
|
show 1 more comment
up vote
-3
down vote
favorite
I was wondering how diff
decides whether a difference is change (i.e. replacement) or combination of addition and deletion?
The best I can find from diffutils' manual is
‘fct’
Replace the lines in range f of the first file with lines in range t
of the second file. This is like a combined add and delete, but more
compact. For example, ‘5,7c8,10’ means change lines 5–7 of file 1 to
read as lines 8–10 of file 2; or,if changing file 2 into file 1,
change lines 8–10 of file 2 to read as lines 5–7 of file
1.
For example, I have two files, each having four lines
$ paste f2 f3
0 1
1 2
3 3
5 6
and I diff them
$ diff f2 f3
1d0
< 0
2a2
> 2
4c4
< 5
---
> 6
Why is
1d0
< 0
2a2
> 2
not
1,2c1,2
< 0
< 1
---
> 1
> 2
instead?
The alternative I gave and the diff
output both have 3
as the common line, but my alternative treats the different lines before the common line as c
i.e. replacement, while the diff
output treats them as a combination of deletion and addition.
text-processing diff
If you read the manual, it saysdiff
tries to minimize the total hunk size by finding large sequences of common lines interspersed with small hunks of differing lines... there are even examples etc...
– don_crissti
4 hours ago
Thanks. Can you be more specific when it comes to my questions?
– Tim
4 hours ago
No. I think the manual is very clear, just read the hunks subsection that I linked to...
– don_crissti
4 hours ago
I have. But I can't relate it here. I was wondering whether I am missing something, or you actually miss my question?
– Tim
4 hours ago
Well, I cannot understand most of your questions but this one is pretty clear... And so is the answer in the manual: In general, there are many ways to match up lines between two given files.
– don_crissti
4 hours ago
|
show 1 more comment
up vote
-3
down vote
favorite
up vote
-3
down vote
favorite
I was wondering how diff
decides whether a difference is change (i.e. replacement) or combination of addition and deletion?
The best I can find from diffutils' manual is
‘fct’
Replace the lines in range f of the first file with lines in range t
of the second file. This is like a combined add and delete, but more
compact. For example, ‘5,7c8,10’ means change lines 5–7 of file 1 to
read as lines 8–10 of file 2; or,if changing file 2 into file 1,
change lines 8–10 of file 2 to read as lines 5–7 of file
1.
For example, I have two files, each having four lines
$ paste f2 f3
0 1
1 2
3 3
5 6
and I diff them
$ diff f2 f3
1d0
< 0
2a2
> 2
4c4
< 5
---
> 6
Why is
1d0
< 0
2a2
> 2
not
1,2c1,2
< 0
< 1
---
> 1
> 2
instead?
The alternative I gave and the diff
output both have 3
as the common line, but my alternative treats the different lines before the common line as c
i.e. replacement, while the diff
output treats them as a combination of deletion and addition.
text-processing diff
I was wondering how diff
decides whether a difference is change (i.e. replacement) or combination of addition and deletion?
The best I can find from diffutils' manual is
‘fct’
Replace the lines in range f of the first file with lines in range t
of the second file. This is like a combined add and delete, but more
compact. For example, ‘5,7c8,10’ means change lines 5–7 of file 1 to
read as lines 8–10 of file 2; or,if changing file 2 into file 1,
change lines 8–10 of file 2 to read as lines 5–7 of file
1.
For example, I have two files, each having four lines
$ paste f2 f3
0 1
1 2
3 3
5 6
and I diff them
$ diff f2 f3
1d0
< 0
2a2
> 2
4c4
< 5
---
> 6
Why is
1d0
< 0
2a2
> 2
not
1,2c1,2
< 0
< 1
---
> 1
> 2
instead?
The alternative I gave and the diff
output both have 3
as the common line, but my alternative treats the different lines before the common line as c
i.e. replacement, while the diff
output treats them as a combination of deletion and addition.
text-processing diff
text-processing diff
edited 3 hours ago
asked 4 hours ago
Tim
24.7k70239431
24.7k70239431
If you read the manual, it saysdiff
tries to minimize the total hunk size by finding large sequences of common lines interspersed with small hunks of differing lines... there are even examples etc...
– don_crissti
4 hours ago
Thanks. Can you be more specific when it comes to my questions?
– Tim
4 hours ago
No. I think the manual is very clear, just read the hunks subsection that I linked to...
– don_crissti
4 hours ago
I have. But I can't relate it here. I was wondering whether I am missing something, or you actually miss my question?
– Tim
4 hours ago
Well, I cannot understand most of your questions but this one is pretty clear... And so is the answer in the manual: In general, there are many ways to match up lines between two given files.
– don_crissti
4 hours ago
|
show 1 more comment
If you read the manual, it saysdiff
tries to minimize the total hunk size by finding large sequences of common lines interspersed with small hunks of differing lines... there are even examples etc...
– don_crissti
4 hours ago
Thanks. Can you be more specific when it comes to my questions?
– Tim
4 hours ago
No. I think the manual is very clear, just read the hunks subsection that I linked to...
– don_crissti
4 hours ago
I have. But I can't relate it here. I was wondering whether I am missing something, or you actually miss my question?
– Tim
4 hours ago
Well, I cannot understand most of your questions but this one is pretty clear... And so is the answer in the manual: In general, there are many ways to match up lines between two given files.
– don_crissti
4 hours ago
If you read the manual, it says
diff
tries to minimize the total hunk size by finding large sequences of common lines interspersed with small hunks of differing lines... there are even examples etc...– don_crissti
4 hours ago
If you read the manual, it says
diff
tries to minimize the total hunk size by finding large sequences of common lines interspersed with small hunks of differing lines... there are even examples etc...– don_crissti
4 hours ago
Thanks. Can you be more specific when it comes to my questions?
– Tim
4 hours ago
Thanks. Can you be more specific when it comes to my questions?
– Tim
4 hours ago
No. I think the manual is very clear, just read the hunks subsection that I linked to...
– don_crissti
4 hours ago
No. I think the manual is very clear, just read the hunks subsection that I linked to...
– don_crissti
4 hours ago
I have. But I can't relate it here. I was wondering whether I am missing something, or you actually miss my question?
– Tim
4 hours ago
I have. But I can't relate it here. I was wondering whether I am missing something, or you actually miss my question?
– Tim
4 hours ago
Well, I cannot understand most of your questions but this one is pretty clear... And so is the answer in the manual: In general, there are many ways to match up lines between two given files.
– don_crissti
4 hours ago
Well, I cannot understand most of your questions but this one is pretty clear... And so is the answer in the manual: In general, there are many ways to match up lines between two given files.
– don_crissti
4 hours ago
|
show 1 more comment
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f480848%2fhow-does-diff-decide-whether-a-difference-is-change-i-e-replacement-or-comb%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
If you read the manual, it says
diff
tries to minimize the total hunk size by finding large sequences of common lines interspersed with small hunks of differing lines... there are even examples etc...– don_crissti
4 hours ago
Thanks. Can you be more specific when it comes to my questions?
– Tim
4 hours ago
No. I think the manual is very clear, just read the hunks subsection that I linked to...
– don_crissti
4 hours ago
I have. But I can't relate it here. I was wondering whether I am missing something, or you actually miss my question?
– Tim
4 hours ago
Well, I cannot understand most of your questions but this one is pretty clear... And so is the answer in the manual: In general, there are many ways to match up lines between two given files.
– don_crissti
4 hours ago