Make the `diff` command look only for differences from a specified range of linesWhat are some good GUI diff and merge applications available for Ubuntu?How to make changes while viewing a diff in bzr explorer?Does “diff” exist for images?Open a file at a certain position and read one byte in bashBest alternative for WinMergeHow to see difference or compare files using sublime?awk - compare files and print lines from both filesdiff - How to make columns line upterminal bell sound interruptingsearching for “created_at”: followed in the next line by “retweeted”: in lots of json files for a specific rangeIdentical content search between files of different names?
Is it possible to trip with natural weapon?
How to make a setting relevant?
When writing an error prompt, should we end the sentence with a exclamation mark or a dot?
Secure offsite backup, even in the case of hacker root access
Will TSA allow me to carry a Continuous Positive Airway Pressure (CPAP)/sleep apnea device?
What happened to all the nuclear material being smuggled after the fall of the USSR?
How can Iron Man's suit withstand this?
Credit card offering 0.5 miles for every cent rounded up. Too good to be true?
Can a magnetic field of an object be stronger than its gravity?
Traffic law UK, pedestrians
What's the logic behind the the organization of Hamburg's bus transport into "rings"?
Count down from 0 to 5 seconds and repeat
How to pass a regex when finding a directory path in bash?
Is there any word or phrase for negative bearing?
Bent spoke design wheels — feasible?
Do manufacturers try make their components as close to ideal ones as possible?
Are the AT-AT's from Empire Strikes back a deliberate reference to Mecha
How do I write "Show, Don't Tell" as an Asperger
Opposite of "Squeaky wheel gets the grease"
Company did not petition for visa in a timely manner. Is asking me to work from overseas, but wants me to take a paycut
C SIGINT signal in Linux
What are the words for people who cause trouble believing they know better?
On the Twin Paradox Again
Removing applications from Show Applications without uninstalling
Make the `diff` command look only for differences from a specified range of lines
What are some good GUI diff and merge applications available for Ubuntu?How to make changes while viewing a diff in bzr explorer?Does “diff” exist for images?Open a file at a certain position and read one byte in bashBest alternative for WinMergeHow to see difference or compare files using sublime?awk - compare files and print lines from both filesdiff - How to make columns line upterminal bell sound interruptingsearching for “created_at”: followed in the next line by “retweeted”: in lots of json files for a specific rangeIdentical content search between files of different names?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Is there a way to make the diff command look only for differences from a specified range of lines (from from line to to line), instead of the entire file? I am having difficulty trying to find the difference between two JavaScript functions in two files that are not on the same line. I could copy the range of lines into a new file, do the same for the other file, then compare them, but it would be tedious to do so especially since the files contain a lot of text.
I tried using:
diff "code1.js" "code2.js" --suppress-common-lines | tee outputFile
but it obviously does not show only the range of lines I am interested in comparing. It would be also useful if I could specify a range of lines to look for in one file and a different range of lines in the other file.
command-line diff
add a comment |
Is there a way to make the diff command look only for differences from a specified range of lines (from from line to to line), instead of the entire file? I am having difficulty trying to find the difference between two JavaScript functions in two files that are not on the same line. I could copy the range of lines into a new file, do the same for the other file, then compare them, but it would be tedious to do so especially since the files contain a lot of text.
I tried using:
diff "code1.js" "code2.js" --suppress-common-lines | tee outputFile
but it obviously does not show only the range of lines I am interested in comparing. It would be also useful if I could specify a range of lines to look for in one file and a different range of lines in the other file.
command-line diff
add a comment |
Is there a way to make the diff command look only for differences from a specified range of lines (from from line to to line), instead of the entire file? I am having difficulty trying to find the difference between two JavaScript functions in two files that are not on the same line. I could copy the range of lines into a new file, do the same for the other file, then compare them, but it would be tedious to do so especially since the files contain a lot of text.
I tried using:
diff "code1.js" "code2.js" --suppress-common-lines | tee outputFile
but it obviously does not show only the range of lines I am interested in comparing. It would be also useful if I could specify a range of lines to look for in one file and a different range of lines in the other file.
command-line diff
Is there a way to make the diff command look only for differences from a specified range of lines (from from line to to line), instead of the entire file? I am having difficulty trying to find the difference between two JavaScript functions in two files that are not on the same line. I could copy the range of lines into a new file, do the same for the other file, then compare them, but it would be tedious to do so especially since the files contain a lot of text.
I tried using:
diff "code1.js" "code2.js" --suppress-common-lines | tee outputFile
but it obviously does not show only the range of lines I am interested in comparing. It would be also useful if I could specify a range of lines to look for in one file and a different range of lines in the other file.
command-line diff
command-line diff
asked May 19 at 18:07
JAT86JAT86
1584
1584
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
diff <(sed -n 'S1,S2p' file1) <(sed -n 'S3,S4p' file2)
where
- S1 is start line file1.
- S2 is end line file1.
- S3 is start line file2.
- S4 is end line file2.
Skipping line 1-4:
diff <(sed -n '5,10p' file1) <(sed -n '5,10p' file2)
$ more file1
1
2
3
4
5
6
7
8
9
10
$ more file2
11
2
3
4
5
65
7
8
9
10
Result
2c2
< 6
---
> 65
-> it skipped the diff on line 1.
It might be easier to use a desktop tool for this. Meld is excellent ( topic on AU: https://askubuntu.com/a/2947/15811 ):
Meld is a visual diff and merge tool targeted at developers. Meld helps you compare files, directories, and version controlled projects. It provides two- and three-way comparison of both files and directories, and has support for many popular version control systems.
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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%2faskubuntu.com%2fquestions%2f1144569%2fmake-the-diff-command-look-only-for-differences-from-a-specified-range-of-line%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
diff <(sed -n 'S1,S2p' file1) <(sed -n 'S3,S4p' file2)
where
- S1 is start line file1.
- S2 is end line file1.
- S3 is start line file2.
- S4 is end line file2.
Skipping line 1-4:
diff <(sed -n '5,10p' file1) <(sed -n '5,10p' file2)
$ more file1
1
2
3
4
5
6
7
8
9
10
$ more file2
11
2
3
4
5
65
7
8
9
10
Result
2c2
< 6
---
> 65
-> it skipped the diff on line 1.
It might be easier to use a desktop tool for this. Meld is excellent ( topic on AU: https://askubuntu.com/a/2947/15811 ):
Meld is a visual diff and merge tool targeted at developers. Meld helps you compare files, directories, and version controlled projects. It provides two- and three-way comparison of both files and directories, and has support for many popular version control systems.
add a comment |
diff <(sed -n 'S1,S2p' file1) <(sed -n 'S3,S4p' file2)
where
- S1 is start line file1.
- S2 is end line file1.
- S3 is start line file2.
- S4 is end line file2.
Skipping line 1-4:
diff <(sed -n '5,10p' file1) <(sed -n '5,10p' file2)
$ more file1
1
2
3
4
5
6
7
8
9
10
$ more file2
11
2
3
4
5
65
7
8
9
10
Result
2c2
< 6
---
> 65
-> it skipped the diff on line 1.
It might be easier to use a desktop tool for this. Meld is excellent ( topic on AU: https://askubuntu.com/a/2947/15811 ):
Meld is a visual diff and merge tool targeted at developers. Meld helps you compare files, directories, and version controlled projects. It provides two- and three-way comparison of both files and directories, and has support for many popular version control systems.
add a comment |
diff <(sed -n 'S1,S2p' file1) <(sed -n 'S3,S4p' file2)
where
- S1 is start line file1.
- S2 is end line file1.
- S3 is start line file2.
- S4 is end line file2.
Skipping line 1-4:
diff <(sed -n '5,10p' file1) <(sed -n '5,10p' file2)
$ more file1
1
2
3
4
5
6
7
8
9
10
$ more file2
11
2
3
4
5
65
7
8
9
10
Result
2c2
< 6
---
> 65
-> it skipped the diff on line 1.
It might be easier to use a desktop tool for this. Meld is excellent ( topic on AU: https://askubuntu.com/a/2947/15811 ):
Meld is a visual diff and merge tool targeted at developers. Meld helps you compare files, directories, and version controlled projects. It provides two- and three-way comparison of both files and directories, and has support for many popular version control systems.
diff <(sed -n 'S1,S2p' file1) <(sed -n 'S3,S4p' file2)
where
- S1 is start line file1.
- S2 is end line file1.
- S3 is start line file2.
- S4 is end line file2.
Skipping line 1-4:
diff <(sed -n '5,10p' file1) <(sed -n '5,10p' file2)
$ more file1
1
2
3
4
5
6
7
8
9
10
$ more file2
11
2
3
4
5
65
7
8
9
10
Result
2c2
< 6
---
> 65
-> it skipped the diff on line 1.
It might be easier to use a desktop tool for this. Meld is excellent ( topic on AU: https://askubuntu.com/a/2947/15811 ):
Meld is a visual diff and merge tool targeted at developers. Meld helps you compare files, directories, and version controlled projects. It provides two- and three-way comparison of both files and directories, and has support for many popular version control systems.
edited May 19 at 18:31
answered May 19 at 18:16
RinzwindRinzwind
214k28413552
214k28413552
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- 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%2faskubuntu.com%2fquestions%2f1144569%2fmake-the-diff-command-look-only-for-differences-from-a-specified-range-of-line%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