Highlight differences between lines The Next CEO of Stack OverflowHow can I get the most bang for my buck with the “diff” command?Compare two similar directories and list differences between filesHighlight differences between two files, similar to what watch -d producesColor output of linux command similar to 'watch -d' to highlight differences?Evaluate differences between two filesGetting differences of file between specific revisions/branchesDiffing for metadata differencesCompare two zip files for differencesHow to produce a diff without lone identical linesuse 'diff-highlight' for diff
In the "Harry Potter and the Order of the Phoenix" video game, what potion is used to sabotage Umbridge's speakers?
Is there a way to save my career from absolute disaster?
Reshaping json / reparing json inside shell script (remove trailing comma)
How do I fit a non linear curve?
Players Circumventing the limitations of Wish
Why is information "lost" when it got into a black hole?
Touchpad not working on Debian 9
Can I board the first leg of the flight without having final country's visa?
Film where the government was corrupt with aliens, people sent to kill aliens are given rigged visors not showing the right aliens
How to avoid supervisors with prejudiced views?
Is there a reasonable and studied concept of reduction between regular languages?
My ex-girlfriend uses my Apple ID to login to her iPad, do I have to give her my Apple ID password to reset it?
"Eavesdropping" vs "Listen in on"
What steps are necessary to read a Modern SSD in Medieval Europe?
Computationally populating tables with probability data
TikZ: How to fill area with a special pattern?
Help! I cannot understand this game’s notations!
Man transported from Alternate World into ours by a Neutrino Detector
Why is the US ranked as #45 in Press Freedom ratings, despite its extremely permissive free speech laws?
What is the difference between "hamstring tendon" and "common hamstring tendon"?
Why doesn't UK go for the same deal Japan has with EU to resolve Brexit?
Is it professional to write unrelated content in an almost-empty email?
Is it correct to say moon starry nights?
Expectation in a stochastic differential equation
Highlight differences between lines
The Next CEO of Stack OverflowHow can I get the most bang for my buck with the “diff” command?Compare two similar directories and list differences between filesHighlight differences between two files, similar to what watch -d producesColor output of linux command similar to 'watch -d' to highlight differences?Evaluate differences between two filesGetting differences of file between specific revisions/branchesDiffing for metadata differencesCompare two zip files for differencesHow to produce a diff without lone identical linesuse 'diff-highlight' for diff
I have a file with near-identical lines which have some slight differences, and I want to have a highlight of the differences between each line.
Example:
- The quick brown fox jumps over the lazy dog.
- The quack brown fox leaps over the lazy dog.
- The quack fox leaps over the very lazy dog.
- The quack fox leaps oer the really very lazy dog.
(here bold text marks characters that have been inserted and changed compared to the previous line, and italics marks characters that are removed in the next line).
The highlighting doesn't need to look exactly like in the example, but it should indicate which characters have been added, changed or removed. And it should indicate this solely with highlighting (ie. no printing of old and new characters in one line), so that the actual text on each line is still identical to the original text.
I have tried to build something with dwdiff
(iterating over the lines and then comparing consecutive lines), but haven't found a way to highlight deleted characters:
infile=$1
line1=
line2=
lineNo=0
while IFS="" read -r nextLine || [ -n "$nextLine" ]; do
line1=$line2
line2=$nextLine
if [[ "$lineNo" -gt 0 ]]; then
dwdiff -1 -c <(printf '%sn' "$line1") <(printf '%sn' "$line2")
else
printf '%sn' "$line2"
fi
lineNo=$((lineNo+1))
done
Ideally the diff would actually work on characters, but word-level differences would be OK as well.
Is there a way to get this result with dwdiff
? Or is there an existing tool which does this?
diff
add a comment |
I have a file with near-identical lines which have some slight differences, and I want to have a highlight of the differences between each line.
Example:
- The quick brown fox jumps over the lazy dog.
- The quack brown fox leaps over the lazy dog.
- The quack fox leaps over the very lazy dog.
- The quack fox leaps oer the really very lazy dog.
(here bold text marks characters that have been inserted and changed compared to the previous line, and italics marks characters that are removed in the next line).
The highlighting doesn't need to look exactly like in the example, but it should indicate which characters have been added, changed or removed. And it should indicate this solely with highlighting (ie. no printing of old and new characters in one line), so that the actual text on each line is still identical to the original text.
I have tried to build something with dwdiff
(iterating over the lines and then comparing consecutive lines), but haven't found a way to highlight deleted characters:
infile=$1
line1=
line2=
lineNo=0
while IFS="" read -r nextLine || [ -n "$nextLine" ]; do
line1=$line2
line2=$nextLine
if [[ "$lineNo" -gt 0 ]]; then
dwdiff -1 -c <(printf '%sn' "$line1") <(printf '%sn' "$line2")
else
printf '%sn' "$line2"
fi
lineNo=$((lineNo+1))
done
Ideally the diff would actually work on characters, but word-level differences would be OK as well.
Is there a way to get this result with dwdiff
? Or is there an existing tool which does this?
diff
Did you miss highlightingoer
in the last line?
– Inian
2 days ago
@Inian: I have only highlighted the deleted "v" character in the line above. Not really easy to see; with colored highlighting this might be more usable. And yes, with word-level differences the entire "oer" would have to be highlighted.
– oliver
2 days ago
add a comment |
I have a file with near-identical lines which have some slight differences, and I want to have a highlight of the differences between each line.
Example:
- The quick brown fox jumps over the lazy dog.
- The quack brown fox leaps over the lazy dog.
- The quack fox leaps over the very lazy dog.
- The quack fox leaps oer the really very lazy dog.
(here bold text marks characters that have been inserted and changed compared to the previous line, and italics marks characters that are removed in the next line).
The highlighting doesn't need to look exactly like in the example, but it should indicate which characters have been added, changed or removed. And it should indicate this solely with highlighting (ie. no printing of old and new characters in one line), so that the actual text on each line is still identical to the original text.
I have tried to build something with dwdiff
(iterating over the lines and then comparing consecutive lines), but haven't found a way to highlight deleted characters:
infile=$1
line1=
line2=
lineNo=0
while IFS="" read -r nextLine || [ -n "$nextLine" ]; do
line1=$line2
line2=$nextLine
if [[ "$lineNo" -gt 0 ]]; then
dwdiff -1 -c <(printf '%sn' "$line1") <(printf '%sn' "$line2")
else
printf '%sn' "$line2"
fi
lineNo=$((lineNo+1))
done
Ideally the diff would actually work on characters, but word-level differences would be OK as well.
Is there a way to get this result with dwdiff
? Or is there an existing tool which does this?
diff
I have a file with near-identical lines which have some slight differences, and I want to have a highlight of the differences between each line.
Example:
- The quick brown fox jumps over the lazy dog.
- The quack brown fox leaps over the lazy dog.
- The quack fox leaps over the very lazy dog.
- The quack fox leaps oer the really very lazy dog.
(here bold text marks characters that have been inserted and changed compared to the previous line, and italics marks characters that are removed in the next line).
The highlighting doesn't need to look exactly like in the example, but it should indicate which characters have been added, changed or removed. And it should indicate this solely with highlighting (ie. no printing of old and new characters in one line), so that the actual text on each line is still identical to the original text.
I have tried to build something with dwdiff
(iterating over the lines and then comparing consecutive lines), but haven't found a way to highlight deleted characters:
infile=$1
line1=
line2=
lineNo=0
while IFS="" read -r nextLine || [ -n "$nextLine" ]; do
line1=$line2
line2=$nextLine
if [[ "$lineNo" -gt 0 ]]; then
dwdiff -1 -c <(printf '%sn' "$line1") <(printf '%sn' "$line2")
else
printf '%sn' "$line2"
fi
lineNo=$((lineNo+1))
done
Ideally the diff would actually work on characters, but word-level differences would be OK as well.
Is there a way to get this result with dwdiff
? Or is there an existing tool which does this?
diff
diff
asked 2 days ago
oliveroliver
28614
28614
Did you miss highlightingoer
in the last line?
– Inian
2 days ago
@Inian: I have only highlighted the deleted "v" character in the line above. Not really easy to see; with colored highlighting this might be more usable. And yes, with word-level differences the entire "oer" would have to be highlighted.
– oliver
2 days ago
add a comment |
Did you miss highlightingoer
in the last line?
– Inian
2 days ago
@Inian: I have only highlighted the deleted "v" character in the line above. Not really easy to see; with colored highlighting this might be more usable. And yes, with word-level differences the entire "oer" would have to be highlighted.
– oliver
2 days ago
Did you miss highlighting
oer
in the last line?– Inian
2 days ago
Did you miss highlighting
oer
in the last line?– Inian
2 days ago
@Inian: I have only highlighted the deleted "v" character in the line above. Not really easy to see; with colored highlighting this might be more usable. And yes, with word-level differences the entire "oer" would have to be highlighted.
– oliver
2 days ago
@Inian: I have only highlighted the deleted "v" character in the line above. Not really easy to see; with colored highlighting this might be more usable. And yes, with word-level differences the entire "oer" would have to be highlighted.
– oliver
2 days ago
add a comment |
0
active
oldest
votes
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f509461%2fhighlight-differences-between-lines%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f509461%2fhighlight-differences-between-lines%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Did you miss highlighting
oer
in the last line?– Inian
2 days ago
@Inian: I have only highlighted the deleted "v" character in the line above. Not really easy to see; with colored highlighting this might be more usable. And yes, with word-level differences the entire "oer" would have to be highlighted.
– oliver
2 days ago