Replacing with sed expressionusing sed for replacing strings with “/”Replacing lines containing a pattern...

English word for "product of tinkering"

GroupBy operation using an entire dataframe to group values

Let M and N be single-digit integers. If the product 2M5 x 13N is divisible by 36, how many ordered pairs (M,N) are possible?

New pedal fell off maybe 50 miles after installation. Should I replace the entire crank, just the arm, or repair the thread?

Who enforces MPAA rating adherence?

Why are trash cans referred to as "zafacón" in Puerto Rico?

Overlapping String-Blocks

Writing an augmented sixth chord on the flattened supertonic

Print lines between start & end pattern, but if end pattern does not exist, don't print

Are polynomials with the same roots identical?

Live action TV show where High school Kids go into the virtual world and have to clear levels

sed + add word before string only if not exists

Artificer Creativity

Second (easy access) account in case my bank screws up

Why am I getting a strange double quote (“) in Open Office instead of the ordinary one (")?

Is it possible to have 2 different but equal size real number sets that have the same mean and standard deviation?

Getting UPS Power from One Room to Another

How to ensure color fidelity of the same file on two computers?

How to handle (one's own) self-harm scars (on the arm), in a work environment?

How to communicate to my GM that not being allowed to use stealth isn't fun for me?

Extreme flexible working hours: how to get to know people and activities?

Why we don’t make use of the t-distribution for constructing a confidence interval for a proportion?

Generate basis elements of the Steenrod algebra

A map of non-pathological topology?



Replacing with sed expression


using sed for replacing strings with “/”Replacing lines containing a pattern with sedSED command not replacing (working regex)Replacing by tab character in Sed in Osxsed - simple regular expression replacement not replacingsed regular expression behaving differently than in vim and perl?Replacing variable containing with sedsed function to replace any config file entryWhy does sed output -e expression #1, char 55: Invalid preceding regular expressionLinux sed command replace two lines having spaces and special characters using regular expression






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







-1















I'm trying to get a value such as



"909,999"


With this (the example is replacing it with nothing):



sed 's/["][0-9]+[,][0-9]+["]//g'


But it's not working.










share|improve this question




















  • 6





    What is the text that you are feeding into sed? Does it work if you run with sed -E (your expression looks like an extended regular expression, unless the pluses are supposed to be literal). Why do you use ["] instead of just "? The double quote is not special in a regular expression. Likewise for the comma. Also, you are replacing the matched thing with nothing.

    – Kusalananda
    3 hours ago




















-1















I'm trying to get a value such as



"909,999"


With this (the example is replacing it with nothing):



sed 's/["][0-9]+[,][0-9]+["]//g'


But it's not working.










share|improve this question




















  • 6





    What is the text that you are feeding into sed? Does it work if you run with sed -E (your expression looks like an extended regular expression, unless the pluses are supposed to be literal). Why do you use ["] instead of just "? The double quote is not special in a regular expression. Likewise for the comma. Also, you are replacing the matched thing with nothing.

    – Kusalananda
    3 hours ago
















-1












-1








-1








I'm trying to get a value such as



"909,999"


With this (the example is replacing it with nothing):



sed 's/["][0-9]+[,][0-9]+["]//g'


But it's not working.










share|improve this question
















I'm trying to get a value such as



"909,999"


With this (the example is replacing it with nothing):



sed 's/["][0-9]+[,][0-9]+["]//g'


But it's not working.







sed regular-expression






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 55 mins ago









Rui F Ribeiro

42.8k1688149




42.8k1688149










asked 3 hours ago









Gabriel A. ZorrillaGabriel A. Zorrilla

249512




249512








  • 6





    What is the text that you are feeding into sed? Does it work if you run with sed -E (your expression looks like an extended regular expression, unless the pluses are supposed to be literal). Why do you use ["] instead of just "? The double quote is not special in a regular expression. Likewise for the comma. Also, you are replacing the matched thing with nothing.

    – Kusalananda
    3 hours ago
















  • 6





    What is the text that you are feeding into sed? Does it work if you run with sed -E (your expression looks like an extended regular expression, unless the pluses are supposed to be literal). Why do you use ["] instead of just "? The double quote is not special in a regular expression. Likewise for the comma. Also, you are replacing the matched thing with nothing.

    – Kusalananda
    3 hours ago










6




6





What is the text that you are feeding into sed? Does it work if you run with sed -E (your expression looks like an extended regular expression, unless the pluses are supposed to be literal). Why do you use ["] instead of just "? The double quote is not special in a regular expression. Likewise for the comma. Also, you are replacing the matched thing with nothing.

– Kusalananda
3 hours ago







What is the text that you are feeding into sed? Does it work if you run with sed -E (your expression looks like an extended regular expression, unless the pluses are supposed to be literal). Why do you use ["] instead of just "? The double quote is not special in a regular expression. Likewise for the comma. Also, you are replacing the matched thing with nothing.

– Kusalananda
3 hours ago












1 Answer
1






active

oldest

votes


















0














If you want to replace the pattern, you can use sed -E or escape the + characters as suggested by @Kusalananda:



$ printf '"123.456"n"909,999"n"100"n' | sed -E 's/"[0-9]+,[0-9]+"//g'
"123.456"

"100"


or



$ printf '"123.456"n"909,999"n"100"n' | sed 's/"[0-9]+,[0-9]+"//g'
"123.456"

"100"


Note that the g is not needed in this example as there is only one substitution per line.





If you want to delete the matching line(s), you could use d to delete the pattern space:



$ printf '"123.456"n"909,999"n"100"n' | sed '/"[0-9]+,[0-9]+"/d'
"123.456"
"100"





share|improve this answer
























    Your Answer








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


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f523415%2freplacing-with-sed-expression%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









    0














    If you want to replace the pattern, you can use sed -E or escape the + characters as suggested by @Kusalananda:



    $ printf '"123.456"n"909,999"n"100"n' | sed -E 's/"[0-9]+,[0-9]+"//g'
    "123.456"

    "100"


    or



    $ printf '"123.456"n"909,999"n"100"n' | sed 's/"[0-9]+,[0-9]+"//g'
    "123.456"

    "100"


    Note that the g is not needed in this example as there is only one substitution per line.





    If you want to delete the matching line(s), you could use d to delete the pattern space:



    $ printf '"123.456"n"909,999"n"100"n' | sed '/"[0-9]+,[0-9]+"/d'
    "123.456"
    "100"





    share|improve this answer




























      0














      If you want to replace the pattern, you can use sed -E or escape the + characters as suggested by @Kusalananda:



      $ printf '"123.456"n"909,999"n"100"n' | sed -E 's/"[0-9]+,[0-9]+"//g'
      "123.456"

      "100"


      or



      $ printf '"123.456"n"909,999"n"100"n' | sed 's/"[0-9]+,[0-9]+"//g'
      "123.456"

      "100"


      Note that the g is not needed in this example as there is only one substitution per line.





      If you want to delete the matching line(s), you could use d to delete the pattern space:



      $ printf '"123.456"n"909,999"n"100"n' | sed '/"[0-9]+,[0-9]+"/d'
      "123.456"
      "100"





      share|improve this answer


























        0












        0








        0







        If you want to replace the pattern, you can use sed -E or escape the + characters as suggested by @Kusalananda:



        $ printf '"123.456"n"909,999"n"100"n' | sed -E 's/"[0-9]+,[0-9]+"//g'
        "123.456"

        "100"


        or



        $ printf '"123.456"n"909,999"n"100"n' | sed 's/"[0-9]+,[0-9]+"//g'
        "123.456"

        "100"


        Note that the g is not needed in this example as there is only one substitution per line.





        If you want to delete the matching line(s), you could use d to delete the pattern space:



        $ printf '"123.456"n"909,999"n"100"n' | sed '/"[0-9]+,[0-9]+"/d'
        "123.456"
        "100"





        share|improve this answer













        If you want to replace the pattern, you can use sed -E or escape the + characters as suggested by @Kusalananda:



        $ printf '"123.456"n"909,999"n"100"n' | sed -E 's/"[0-9]+,[0-9]+"//g'
        "123.456"

        "100"


        or



        $ printf '"123.456"n"909,999"n"100"n' | sed 's/"[0-9]+,[0-9]+"//g'
        "123.456"

        "100"


        Note that the g is not needed in this example as there is only one substitution per line.





        If you want to delete the matching line(s), you could use d to delete the pattern space:



        $ printf '"123.456"n"909,999"n"100"n' | sed '/"[0-9]+,[0-9]+"/d'
        "123.456"
        "100"






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 2 hours ago









        FreddyFreddy

        4,1831420




        4,1831420






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f523415%2freplacing-with-sed-expression%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

            Hudson River Historic District Contents Geography History The district today Aesthetics Cultural...

            The number designs the writing. Feandra Aversely Definition: The act of ingrafting a sprig or shoot of one...

            Ayherre Geografie Demografie Externe links Navigatiemenu43° 23′ NB, 1° 15′ WL43° 23′ NB, 1°...