sed with PCRE (like grep -P)











up vote
2
down vote

favorite












I am happy that grep does support Python Compatiable Regular Expressions with the -P option.



Is there a reason why the tool sed does not have this feature?










share|improve this question




















  • 6




    It's Perl Compatible Regular Expressions though... ;-)
    – Byte Commander
    Jun 29 at 11:39










  • Same question from 2012 on the Mailing List
    – RoVo
    Jun 29 at 11:41















up vote
2
down vote

favorite












I am happy that grep does support Python Compatiable Regular Expressions with the -P option.



Is there a reason why the tool sed does not have this feature?










share|improve this question




















  • 6




    It's Perl Compatible Regular Expressions though... ;-)
    – Byte Commander
    Jun 29 at 11:39










  • Same question from 2012 on the Mailing List
    – RoVo
    Jun 29 at 11:41













up vote
2
down vote

favorite









up vote
2
down vote

favorite











I am happy that grep does support Python Compatiable Regular Expressions with the -P option.



Is there a reason why the tool sed does not have this feature?










share|improve this question















I am happy that grep does support Python Compatiable Regular Expressions with the -P option.



Is there a reason why the tool sed does not have this feature?







sed regex






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 29 at 16:14









muru

134k19285484




134k19285484










asked Jun 29 at 11:32









guettli

66142063




66142063








  • 6




    It's Perl Compatible Regular Expressions though... ;-)
    – Byte Commander
    Jun 29 at 11:39










  • Same question from 2012 on the Mailing List
    – RoVo
    Jun 29 at 11:41














  • 6




    It's Perl Compatible Regular Expressions though... ;-)
    – Byte Commander
    Jun 29 at 11:39










  • Same question from 2012 on the Mailing List
    – RoVo
    Jun 29 at 11:41








6




6




It's Perl Compatible Regular Expressions though... ;-)
– Byte Commander
Jun 29 at 11:39




It's Perl Compatible Regular Expressions though... ;-)
– Byte Commander
Jun 29 at 11:39












Same question from 2012 on the Mailing List
– RoVo
Jun 29 at 11:41




Same question from 2012 on the Mailing List
– RoVo
Jun 29 at 11:41










2 Answers
2






active

oldest

votes

















up vote
4
down vote













In the case of GNU Sed, the stated reason appears to be




I was afraid it fell into one of those 'cracks'...though from
what was said at the time, some part of the work was already
done and it looked like a matter of docs and packaging...
(though, I admit, in Computer Sci, the last 10% of the work
often takes 90% of the time...




See GNU bug report logs - #22801
status on committed change: upgrading 'sed' RE's to include perlRE syntax - or search the sed-devel Archives for "PCRE" if you want more details.



Don't forget you can use perl itself for many of the simple one-liners for which you might want to use PCRE in sed.






share|improve this answer




























    up vote
    0
    down vote













    Work-around:



    You can use the Pathological Eclectic Rubbish Lister:



    perl -pe 's/../../g' file


    or inline replace:



    perl -pie 's/../../g' file


    This works for the cases where I use sed. If things get more complicated I write a small python script.






    share|improve this answer























    • Well that's great for substitution, but how would you do other sed stuff in Perl? like for example /delete this line/ d
      – wjandrea
      Nov 26 at 15:34








    • 1




      The most promising thing I found after a quick search is s2p (sed to Perl), though I just tried it and the output was VERY verbose.
      – wjandrea
      Nov 26 at 16:00








    • 1




      @wjandrea I updated the answer: "This works for the cases where I use sed. If things get more complicated I write a small python script."
      – guettli
      Nov 27 at 8:06













    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',
    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%2f1050693%2fsed-with-pcre-like-grep-p%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    4
    down vote













    In the case of GNU Sed, the stated reason appears to be




    I was afraid it fell into one of those 'cracks'...though from
    what was said at the time, some part of the work was already
    done and it looked like a matter of docs and packaging...
    (though, I admit, in Computer Sci, the last 10% of the work
    often takes 90% of the time...




    See GNU bug report logs - #22801
    status on committed change: upgrading 'sed' RE's to include perlRE syntax - or search the sed-devel Archives for "PCRE" if you want more details.



    Don't forget you can use perl itself for many of the simple one-liners for which you might want to use PCRE in sed.






    share|improve this answer

























      up vote
      4
      down vote













      In the case of GNU Sed, the stated reason appears to be




      I was afraid it fell into one of those 'cracks'...though from
      what was said at the time, some part of the work was already
      done and it looked like a matter of docs and packaging...
      (though, I admit, in Computer Sci, the last 10% of the work
      often takes 90% of the time...




      See GNU bug report logs - #22801
      status on committed change: upgrading 'sed' RE's to include perlRE syntax - or search the sed-devel Archives for "PCRE" if you want more details.



      Don't forget you can use perl itself for many of the simple one-liners for which you might want to use PCRE in sed.






      share|improve this answer























        up vote
        4
        down vote










        up vote
        4
        down vote









        In the case of GNU Sed, the stated reason appears to be




        I was afraid it fell into one of those 'cracks'...though from
        what was said at the time, some part of the work was already
        done and it looked like a matter of docs and packaging...
        (though, I admit, in Computer Sci, the last 10% of the work
        often takes 90% of the time...




        See GNU bug report logs - #22801
        status on committed change: upgrading 'sed' RE's to include perlRE syntax - or search the sed-devel Archives for "PCRE" if you want more details.



        Don't forget you can use perl itself for many of the simple one-liners for which you might want to use PCRE in sed.






        share|improve this answer












        In the case of GNU Sed, the stated reason appears to be




        I was afraid it fell into one of those 'cracks'...though from
        what was said at the time, some part of the work was already
        done and it looked like a matter of docs and packaging...
        (though, I admit, in Computer Sci, the last 10% of the work
        often takes 90% of the time...




        See GNU bug report logs - #22801
        status on committed change: upgrading 'sed' RE's to include perlRE syntax - or search the sed-devel Archives for "PCRE" if you want more details.



        Don't forget you can use perl itself for many of the simple one-liners for which you might want to use PCRE in sed.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jun 29 at 11:43









        steeldriver

        64.9k11103173




        64.9k11103173
























            up vote
            0
            down vote













            Work-around:



            You can use the Pathological Eclectic Rubbish Lister:



            perl -pe 's/../../g' file


            or inline replace:



            perl -pie 's/../../g' file


            This works for the cases where I use sed. If things get more complicated I write a small python script.






            share|improve this answer























            • Well that's great for substitution, but how would you do other sed stuff in Perl? like for example /delete this line/ d
              – wjandrea
              Nov 26 at 15:34








            • 1




              The most promising thing I found after a quick search is s2p (sed to Perl), though I just tried it and the output was VERY verbose.
              – wjandrea
              Nov 26 at 16:00








            • 1




              @wjandrea I updated the answer: "This works for the cases where I use sed. If things get more complicated I write a small python script."
              – guettli
              Nov 27 at 8:06

















            up vote
            0
            down vote













            Work-around:



            You can use the Pathological Eclectic Rubbish Lister:



            perl -pe 's/../../g' file


            or inline replace:



            perl -pie 's/../../g' file


            This works for the cases where I use sed. If things get more complicated I write a small python script.






            share|improve this answer























            • Well that's great for substitution, but how would you do other sed stuff in Perl? like for example /delete this line/ d
              – wjandrea
              Nov 26 at 15:34








            • 1




              The most promising thing I found after a quick search is s2p (sed to Perl), though I just tried it and the output was VERY verbose.
              – wjandrea
              Nov 26 at 16:00








            • 1




              @wjandrea I updated the answer: "This works for the cases where I use sed. If things get more complicated I write a small python script."
              – guettli
              Nov 27 at 8:06















            up vote
            0
            down vote










            up vote
            0
            down vote









            Work-around:



            You can use the Pathological Eclectic Rubbish Lister:



            perl -pe 's/../../g' file


            or inline replace:



            perl -pie 's/../../g' file


            This works for the cases where I use sed. If things get more complicated I write a small python script.






            share|improve this answer














            Work-around:



            You can use the Pathological Eclectic Rubbish Lister:



            perl -pe 's/../../g' file


            or inline replace:



            perl -pie 's/../../g' file


            This works for the cases where I use sed. If things get more complicated I write a small python script.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 27 at 8:05

























            answered Nov 26 at 15:30









            guettli

            66142063




            66142063












            • Well that's great for substitution, but how would you do other sed stuff in Perl? like for example /delete this line/ d
              – wjandrea
              Nov 26 at 15:34








            • 1




              The most promising thing I found after a quick search is s2p (sed to Perl), though I just tried it and the output was VERY verbose.
              – wjandrea
              Nov 26 at 16:00








            • 1




              @wjandrea I updated the answer: "This works for the cases where I use sed. If things get more complicated I write a small python script."
              – guettli
              Nov 27 at 8:06




















            • Well that's great for substitution, but how would you do other sed stuff in Perl? like for example /delete this line/ d
              – wjandrea
              Nov 26 at 15:34








            • 1




              The most promising thing I found after a quick search is s2p (sed to Perl), though I just tried it and the output was VERY verbose.
              – wjandrea
              Nov 26 at 16:00








            • 1




              @wjandrea I updated the answer: "This works for the cases where I use sed. If things get more complicated I write a small python script."
              – guettli
              Nov 27 at 8:06


















            Well that's great for substitution, but how would you do other sed stuff in Perl? like for example /delete this line/ d
            – wjandrea
            Nov 26 at 15:34






            Well that's great for substitution, but how would you do other sed stuff in Perl? like for example /delete this line/ d
            – wjandrea
            Nov 26 at 15:34






            1




            1




            The most promising thing I found after a quick search is s2p (sed to Perl), though I just tried it and the output was VERY verbose.
            – wjandrea
            Nov 26 at 16:00






            The most promising thing I found after a quick search is s2p (sed to Perl), though I just tried it and the output was VERY verbose.
            – wjandrea
            Nov 26 at 16:00






            1




            1




            @wjandrea I updated the answer: "This works for the cases where I use sed. If things get more complicated I write a small python script."
            – guettli
            Nov 27 at 8:06






            @wjandrea I updated the answer: "This works for the cases where I use sed. If things get more complicated I write a small python script."
            – guettli
            Nov 27 at 8:06




















            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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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%2f1050693%2fsed-with-pcre-like-grep-p%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

            flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

            Mangá

            Eduardo VII do Reino Unido