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;








5















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.










share|improve this question




























    5















    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.










    share|improve this question
























      5












      5








      5








      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.










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked May 19 at 18:07









      JAT86JAT86

      1584




      1584




















          1 Answer
          1






          active

          oldest

          votes


















          9














          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.







          share|improve this answer

























            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
            );



            );













            draft saved

            draft discarded


















            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









            9














            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.







            share|improve this answer





























              9














              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.







              share|improve this answer



























                9












                9








                9







                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.







                share|improve this answer















                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.








                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited May 19 at 18:31

























                answered May 19 at 18:16









                RinzwindRinzwind

                214k28413552




                214k28413552



























                    draft saved

                    draft discarded
















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    How to write a 12-bar blues melodyI-IV-V blues progressionHow to play the bridges in a standard blues progressionHow does Gdim7 fit in C# minor?question on a certain chord progressionMusicology of Melody12 bar blues, spread rhythm: alternative to 6th chord to avoid finger stretchChord progressions/ Root key/ MelodiesHow to put chords (POP-EDM) under a given lead vocal melody (starting from a good knowledge in music theory)Are there “rules” for improvising with the minor pentatonic scale over 12-bar shuffle?Confusion about blues scale and chords

                    What if the end-user didn't have the required library?What is setup.py?What is a clean, pythonic way to have multiple constructors in Python?What does Ruby have that Python doesn't, and vice versa?What is the reason for having '//' in Python?How do I create a namespace package in Python?How to package shared objects that python modules depend on?setuptools vs. distutils: why is distutils still a thing?Navigation in Windows 10 vs code not going to virtualenv library when the same library is installed at user levelPython create package for local usePackaging a project that uses multiple python versionsWhy is permission denied on pip install except for when “--user” is included at end of command?

                    Why did Thanos need his ship to help him in the battle scene?Which actor plays Thanos in the Avengers mid-credits scene?Are there economic implications portrayed in comics where the buildings and cities are ruined almost daily?Old X-Men comic where team travels to alien world with a ring-like sun that needs recharging?Why does Ego need help sleeping?Is there an objective answer to who “the strongest Avenger” is?How did Banner get unstuck?Why did Thanos get hit?How did Thanos (or anyone) know the Infinity Stones would give him this power?Did Thanos leave Eitri alive for his after-sales service?In Avengers 1, why does Thanos need Loki?