sed + add word before string only if not existssed + remove char after specific wordAdd text before last matched occurrence of search word in a fileAdd specific word to each linePrint line only if the upper line include specific wordGrep for word stem and print only word (and not line)how to add string if word ended with specific stringsed + mark line in case of marched wordawk + append lines before captured word only if lines are not defined in the fileHow to add properties in the end of the two first lines with double quote?add backslash before specific character

How do I turn off a repeating trade?

Impossible darts scores

How long would it take to cross the Channel in 1890's?

What are the penalties for overstaying in USA?

Find the probability that the 8th woman to appear is in 17th position.

Find the C-factor of a vote

Where can I find a database of galactic spectra?

Suggested order for Amazon Prime Doctor Who series

How to get cool night-vision without lame drawbacks?

Employer wants to use my work email account after I quit

Unusual mail headers, evidence of an attempted attack. Have I been pwned?

How do I respond to requests for a "guarantee" not to leave after a few months?

Is this one of the engines from the 9/11 aircraft?

3D Crossword, Cryptic, Statue View & Maze

Are all instances of trolls turning to stone ultimately references back to Tolkien?

C-152 carb heat on before landing in hot weather?

Is there a way to split the metadata to custom folders?

Should I prioritize my 401(k) over my student loans?

Does Marvel have an equivalent of the Green Lantern?

Hand soldering SMD 1206 components

How to make clear to people I don't want to answer their "Where are you from?" question?

Archery in modern conflicts

Fill NAs in R with zero if the next valid data point is more than 2 intervals away

Cascading Repair Costs following Blown Head Gasket on a 2004 Subaru Outback



sed + add word before string only if not exists


sed + remove char after specific wordAdd text before last matched occurrence of search word in a fileAdd specific word to each linePrint line only if the upper line include specific wordGrep for word stem and print only word (and not line)how to add string if word ended with specific stringsed + mark line in case of marched wordawk + append lines before captured word only if lines are not defined in the fileHow to add properties in the end of the two first lines with double quote?add backslash before specific character






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








2















We have the following line in a file on Linux:



discovery.uri=http://master.navada.com:8800


we want to add the word koko before master, so I just do:



sed –i 's/master/kokomaster/' file


which gives:



discovery.uri=http://kokomaster.navada.com:8800


but what we want is to add koko only if koko isn't already present before master.



For example, the next time that we run



sed –i 's/master/kokomaster/' file


the line will be:



discovery.uri=http://kokokokomaster.navada.com:8800









share|improve this question






























    2















    We have the following line in a file on Linux:



    discovery.uri=http://master.navada.com:8800


    we want to add the word koko before master, so I just do:



    sed –i 's/master/kokomaster/' file


    which gives:



    discovery.uri=http://kokomaster.navada.com:8800


    but what we want is to add koko only if koko isn't already present before master.



    For example, the next time that we run



    sed –i 's/master/kokomaster/' file


    the line will be:



    discovery.uri=http://kokokokomaster.navada.com:8800









    share|improve this question


























      2












      2








      2








      We have the following line in a file on Linux:



      discovery.uri=http://master.navada.com:8800


      we want to add the word koko before master, so I just do:



      sed –i 's/master/kokomaster/' file


      which gives:



      discovery.uri=http://kokomaster.navada.com:8800


      but what we want is to add koko only if koko isn't already present before master.



      For example, the next time that we run



      sed –i 's/master/kokomaster/' file


      the line will be:



      discovery.uri=http://kokokokomaster.navada.com:8800









      share|improve this question
















      We have the following line in a file on Linux:



      discovery.uri=http://master.navada.com:8800


      we want to add the word koko before master, so I just do:



      sed –i 's/master/kokomaster/' file


      which gives:



      discovery.uri=http://kokomaster.navada.com:8800


      but what we want is to add koko only if koko isn't already present before master.



      For example, the next time that we run



      sed –i 's/master/kokomaster/' file


      the line will be:



      discovery.uri=http://kokokokomaster.navada.com:8800






      text-processing sed configuration






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jun 6 at 13:27









      terdon

      137k33 gold badges283 silver badges459 bronze badges




      137k33 gold badges283 silver badges459 bronze badges










      asked Jun 6 at 12:12









      yaelyael

      2,9028 gold badges39 silver badges87 bronze badges




      2,9028 gold badges39 silver badges87 bronze badges




















          5 Answers
          5






          active

          oldest

          votes


















          4














          You can replace a bit more to avoid this problem:



          sed -i sX/masterX/kokomasterX file


          This replaces “/master”, so the next time you run it, nothing will be replaced, since “/kokomaster” doesn’t match.






          share|improve this answer






























            4














            sed -i '/kokomaster/!s/master/koko&/' file


            First test whether the string kokomaster exists on the line, and if it doesn't, do the substitution. This is almost a literal translation of "but what we want is to add the koko word only if koko not exists before master word" into sed.



            The & in the replacement part of the substitution will be replaced by the text matched by the pattern part (i.e. master).




            After reading the comments (see below), you may want to use something more specific that would actually only modify the server name portion of the URI, and not any master string elsewhere, even if kokomaster occurred (or not) in the URI path:



            sed -i 's,^(discovery.uri=http://)(master),1koko2,' file


            You may even want to go as far as matching the exact and full line that you'd want to replace, just to avoid even hypothetical mistakes:



            sed -i 's,^(discovery.uri=http://)(master.navada.com:8800)$,1koko2,' file


            If the configuration file is written in JSON or some other well know format, you would not use sed at all, but jq or some other apropriate tool specifically written for handling files of that format.






            share|improve this answer




















            • 1





              That wouldn't work on discovery.uri=http://master.navada.com:8800/kokomaster though.

              – Stéphane Chazelas
              Jun 6 at 13:54











            • @StéphaneChazelas Correct, as per the explicit specification from the user.

              – Kusalananda
              Jun 6 at 14:51












            • Not sure I follow. In discovery.uri=http://master.navada.com:8800/kokomaster, there's no koko before the first master. Yet, that sed line doesn't add one.

              – Stéphane Chazelas
              Jun 6 at 14:54











            • @StéphaneChazelas Sorry, that was half a joke, but it is actually what the user specified. If the string koko does not already occur before master, it should not be added again. That's what's requested, and that's what I did, pedantically following the request to the letter. In your string, koko already occurs right before master, so it's not added again.

              – Kusalananda
              Jun 6 at 15:35











            • @Kusalananda nope. The master in the server name needs to be replaced even if there may be some kokomaster in the path. Pedanticly. I guess the OP doesn't care.

              – Philippos
              Jun 6 at 16:32


















            3














            Use



            sed 's/(koko)*master/kokomaster/'


            so master and any number of preceeding kokos get replaced.






            share|improve this answer























            • Or better, sed 's/(koko)0,1master/kokomaster/' to avoid replacing kokokokomaster with kokomaster.

              – Stéphane Chazelas
              Jun 6 at 13:52


















            2














            If you're open to other tools:



            perl -i -pe 's/(?<!koko)master/kokomaster/' file


            The (?>!foo) is a negative lookbehind, so (?<!koko)master will only match master when not preceded by koko.






            share|improve this answer
































              2














              I have used below awk command to do the same



              command



              awk '$0 !~/kokomaster/gsub("master","kokomaster",$0)1' filename >file_tmp && mv file_tmp filename


              output



              discovery.uri=http://kokomaster.navada.com:8800
              discovery.uri=http://kokomaster.navada.com:8800





              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%2f523302%2fsed-add-word-before-string-only-if-not-exists%23new-answer', 'question_page');

                );

                Post as a guest















                Required, but never shown

























                5 Answers
                5






                active

                oldest

                votes








                5 Answers
                5






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                4














                You can replace a bit more to avoid this problem:



                sed -i sX/masterX/kokomasterX file


                This replaces “/master”, so the next time you run it, nothing will be replaced, since “/kokomaster” doesn’t match.






                share|improve this answer



























                  4














                  You can replace a bit more to avoid this problem:



                  sed -i sX/masterX/kokomasterX file


                  This replaces “/master”, so the next time you run it, nothing will be replaced, since “/kokomaster” doesn’t match.






                  share|improve this answer

























                    4












                    4








                    4







                    You can replace a bit more to avoid this problem:



                    sed -i sX/masterX/kokomasterX file


                    This replaces “/master”, so the next time you run it, nothing will be replaced, since “/kokomaster” doesn’t match.






                    share|improve this answer













                    You can replace a bit more to avoid this problem:



                    sed -i sX/masterX/kokomasterX file


                    This replaces “/master”, so the next time you run it, nothing will be replaced, since “/kokomaster” doesn’t match.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jun 6 at 12:15









                    Stephen KittStephen Kitt

                    191k26 gold badges457 silver badges528 bronze badges




                    191k26 gold badges457 silver badges528 bronze badges























                        4














                        sed -i '/kokomaster/!s/master/koko&/' file


                        First test whether the string kokomaster exists on the line, and if it doesn't, do the substitution. This is almost a literal translation of "but what we want is to add the koko word only if koko not exists before master word" into sed.



                        The & in the replacement part of the substitution will be replaced by the text matched by the pattern part (i.e. master).




                        After reading the comments (see below), you may want to use something more specific that would actually only modify the server name portion of the URI, and not any master string elsewhere, even if kokomaster occurred (or not) in the URI path:



                        sed -i 's,^(discovery.uri=http://)(master),1koko2,' file


                        You may even want to go as far as matching the exact and full line that you'd want to replace, just to avoid even hypothetical mistakes:



                        sed -i 's,^(discovery.uri=http://)(master.navada.com:8800)$,1koko2,' file


                        If the configuration file is written in JSON or some other well know format, you would not use sed at all, but jq or some other apropriate tool specifically written for handling files of that format.






                        share|improve this answer




















                        • 1





                          That wouldn't work on discovery.uri=http://master.navada.com:8800/kokomaster though.

                          – Stéphane Chazelas
                          Jun 6 at 13:54











                        • @StéphaneChazelas Correct, as per the explicit specification from the user.

                          – Kusalananda
                          Jun 6 at 14:51












                        • Not sure I follow. In discovery.uri=http://master.navada.com:8800/kokomaster, there's no koko before the first master. Yet, that sed line doesn't add one.

                          – Stéphane Chazelas
                          Jun 6 at 14:54











                        • @StéphaneChazelas Sorry, that was half a joke, but it is actually what the user specified. If the string koko does not already occur before master, it should not be added again. That's what's requested, and that's what I did, pedantically following the request to the letter. In your string, koko already occurs right before master, so it's not added again.

                          – Kusalananda
                          Jun 6 at 15:35











                        • @Kusalananda nope. The master in the server name needs to be replaced even if there may be some kokomaster in the path. Pedanticly. I guess the OP doesn't care.

                          – Philippos
                          Jun 6 at 16:32















                        4














                        sed -i '/kokomaster/!s/master/koko&/' file


                        First test whether the string kokomaster exists on the line, and if it doesn't, do the substitution. This is almost a literal translation of "but what we want is to add the koko word only if koko not exists before master word" into sed.



                        The & in the replacement part of the substitution will be replaced by the text matched by the pattern part (i.e. master).




                        After reading the comments (see below), you may want to use something more specific that would actually only modify the server name portion of the URI, and not any master string elsewhere, even if kokomaster occurred (or not) in the URI path:



                        sed -i 's,^(discovery.uri=http://)(master),1koko2,' file


                        You may even want to go as far as matching the exact and full line that you'd want to replace, just to avoid even hypothetical mistakes:



                        sed -i 's,^(discovery.uri=http://)(master.navada.com:8800)$,1koko2,' file


                        If the configuration file is written in JSON or some other well know format, you would not use sed at all, but jq or some other apropriate tool specifically written for handling files of that format.






                        share|improve this answer




















                        • 1





                          That wouldn't work on discovery.uri=http://master.navada.com:8800/kokomaster though.

                          – Stéphane Chazelas
                          Jun 6 at 13:54











                        • @StéphaneChazelas Correct, as per the explicit specification from the user.

                          – Kusalananda
                          Jun 6 at 14:51












                        • Not sure I follow. In discovery.uri=http://master.navada.com:8800/kokomaster, there's no koko before the first master. Yet, that sed line doesn't add one.

                          – Stéphane Chazelas
                          Jun 6 at 14:54











                        • @StéphaneChazelas Sorry, that was half a joke, but it is actually what the user specified. If the string koko does not already occur before master, it should not be added again. That's what's requested, and that's what I did, pedantically following the request to the letter. In your string, koko already occurs right before master, so it's not added again.

                          – Kusalananda
                          Jun 6 at 15:35











                        • @Kusalananda nope. The master in the server name needs to be replaced even if there may be some kokomaster in the path. Pedanticly. I guess the OP doesn't care.

                          – Philippos
                          Jun 6 at 16:32













                        4












                        4








                        4







                        sed -i '/kokomaster/!s/master/koko&/' file


                        First test whether the string kokomaster exists on the line, and if it doesn't, do the substitution. This is almost a literal translation of "but what we want is to add the koko word only if koko not exists before master word" into sed.



                        The & in the replacement part of the substitution will be replaced by the text matched by the pattern part (i.e. master).




                        After reading the comments (see below), you may want to use something more specific that would actually only modify the server name portion of the URI, and not any master string elsewhere, even if kokomaster occurred (or not) in the URI path:



                        sed -i 's,^(discovery.uri=http://)(master),1koko2,' file


                        You may even want to go as far as matching the exact and full line that you'd want to replace, just to avoid even hypothetical mistakes:



                        sed -i 's,^(discovery.uri=http://)(master.navada.com:8800)$,1koko2,' file


                        If the configuration file is written in JSON or some other well know format, you would not use sed at all, but jq or some other apropriate tool specifically written for handling files of that format.






                        share|improve this answer















                        sed -i '/kokomaster/!s/master/koko&/' file


                        First test whether the string kokomaster exists on the line, and if it doesn't, do the substitution. This is almost a literal translation of "but what we want is to add the koko word only if koko not exists before master word" into sed.



                        The & in the replacement part of the substitution will be replaced by the text matched by the pattern part (i.e. master).




                        After reading the comments (see below), you may want to use something more specific that would actually only modify the server name portion of the URI, and not any master string elsewhere, even if kokomaster occurred (or not) in the URI path:



                        sed -i 's,^(discovery.uri=http://)(master),1koko2,' file


                        You may even want to go as far as matching the exact and full line that you'd want to replace, just to avoid even hypothetical mistakes:



                        sed -i 's,^(discovery.uri=http://)(master.navada.com:8800)$,1koko2,' file


                        If the configuration file is written in JSON or some other well know format, you would not use sed at all, but jq or some other apropriate tool specifically written for handling files of that format.







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Jun 6 at 16:50

























                        answered Jun 6 at 12:52









                        KusalanandaKusalananda

                        152k18 gold badges298 silver badges478 bronze badges




                        152k18 gold badges298 silver badges478 bronze badges







                        • 1





                          That wouldn't work on discovery.uri=http://master.navada.com:8800/kokomaster though.

                          – Stéphane Chazelas
                          Jun 6 at 13:54











                        • @StéphaneChazelas Correct, as per the explicit specification from the user.

                          – Kusalananda
                          Jun 6 at 14:51












                        • Not sure I follow. In discovery.uri=http://master.navada.com:8800/kokomaster, there's no koko before the first master. Yet, that sed line doesn't add one.

                          – Stéphane Chazelas
                          Jun 6 at 14:54











                        • @StéphaneChazelas Sorry, that was half a joke, but it is actually what the user specified. If the string koko does not already occur before master, it should not be added again. That's what's requested, and that's what I did, pedantically following the request to the letter. In your string, koko already occurs right before master, so it's not added again.

                          – Kusalananda
                          Jun 6 at 15:35











                        • @Kusalananda nope. The master in the server name needs to be replaced even if there may be some kokomaster in the path. Pedanticly. I guess the OP doesn't care.

                          – Philippos
                          Jun 6 at 16:32












                        • 1





                          That wouldn't work on discovery.uri=http://master.navada.com:8800/kokomaster though.

                          – Stéphane Chazelas
                          Jun 6 at 13:54











                        • @StéphaneChazelas Correct, as per the explicit specification from the user.

                          – Kusalananda
                          Jun 6 at 14:51












                        • Not sure I follow. In discovery.uri=http://master.navada.com:8800/kokomaster, there's no koko before the first master. Yet, that sed line doesn't add one.

                          – Stéphane Chazelas
                          Jun 6 at 14:54











                        • @StéphaneChazelas Sorry, that was half a joke, but it is actually what the user specified. If the string koko does not already occur before master, it should not be added again. That's what's requested, and that's what I did, pedantically following the request to the letter. In your string, koko already occurs right before master, so it's not added again.

                          – Kusalananda
                          Jun 6 at 15:35











                        • @Kusalananda nope. The master in the server name needs to be replaced even if there may be some kokomaster in the path. Pedanticly. I guess the OP doesn't care.

                          – Philippos
                          Jun 6 at 16:32







                        1




                        1





                        That wouldn't work on discovery.uri=http://master.navada.com:8800/kokomaster though.

                        – Stéphane Chazelas
                        Jun 6 at 13:54





                        That wouldn't work on discovery.uri=http://master.navada.com:8800/kokomaster though.

                        – Stéphane Chazelas
                        Jun 6 at 13:54













                        @StéphaneChazelas Correct, as per the explicit specification from the user.

                        – Kusalananda
                        Jun 6 at 14:51






                        @StéphaneChazelas Correct, as per the explicit specification from the user.

                        – Kusalananda
                        Jun 6 at 14:51














                        Not sure I follow. In discovery.uri=http://master.navada.com:8800/kokomaster, there's no koko before the first master. Yet, that sed line doesn't add one.

                        – Stéphane Chazelas
                        Jun 6 at 14:54





                        Not sure I follow. In discovery.uri=http://master.navada.com:8800/kokomaster, there's no koko before the first master. Yet, that sed line doesn't add one.

                        – Stéphane Chazelas
                        Jun 6 at 14:54













                        @StéphaneChazelas Sorry, that was half a joke, but it is actually what the user specified. If the string koko does not already occur before master, it should not be added again. That's what's requested, and that's what I did, pedantically following the request to the letter. In your string, koko already occurs right before master, so it's not added again.

                        – Kusalananda
                        Jun 6 at 15:35





                        @StéphaneChazelas Sorry, that was half a joke, but it is actually what the user specified. If the string koko does not already occur before master, it should not be added again. That's what's requested, and that's what I did, pedantically following the request to the letter. In your string, koko already occurs right before master, so it's not added again.

                        – Kusalananda
                        Jun 6 at 15:35













                        @Kusalananda nope. The master in the server name needs to be replaced even if there may be some kokomaster in the path. Pedanticly. I guess the OP doesn't care.

                        – Philippos
                        Jun 6 at 16:32





                        @Kusalananda nope. The master in the server name needs to be replaced even if there may be some kokomaster in the path. Pedanticly. I guess the OP doesn't care.

                        – Philippos
                        Jun 6 at 16:32











                        3














                        Use



                        sed 's/(koko)*master/kokomaster/'


                        so master and any number of preceeding kokos get replaced.






                        share|improve this answer























                        • Or better, sed 's/(koko)0,1master/kokomaster/' to avoid replacing kokokokomaster with kokomaster.

                          – Stéphane Chazelas
                          Jun 6 at 13:52















                        3














                        Use



                        sed 's/(koko)*master/kokomaster/'


                        so master and any number of preceeding kokos get replaced.






                        share|improve this answer























                        • Or better, sed 's/(koko)0,1master/kokomaster/' to avoid replacing kokokokomaster with kokomaster.

                          – Stéphane Chazelas
                          Jun 6 at 13:52













                        3












                        3








                        3







                        Use



                        sed 's/(koko)*master/kokomaster/'


                        so master and any number of preceeding kokos get replaced.






                        share|improve this answer













                        Use



                        sed 's/(koko)*master/kokomaster/'


                        so master and any number of preceeding kokos get replaced.







                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Jun 6 at 12:46









                        PhilipposPhilippos

                        6,5961 gold badge19 silver badges51 bronze badges




                        6,5961 gold badge19 silver badges51 bronze badges












                        • Or better, sed 's/(koko)0,1master/kokomaster/' to avoid replacing kokokokomaster with kokomaster.

                          – Stéphane Chazelas
                          Jun 6 at 13:52

















                        • Or better, sed 's/(koko)0,1master/kokomaster/' to avoid replacing kokokokomaster with kokomaster.

                          – Stéphane Chazelas
                          Jun 6 at 13:52
















                        Or better, sed 's/(koko)0,1master/kokomaster/' to avoid replacing kokokokomaster with kokomaster.

                        – Stéphane Chazelas
                        Jun 6 at 13:52





                        Or better, sed 's/(koko)0,1master/kokomaster/' to avoid replacing kokokokomaster with kokomaster.

                        – Stéphane Chazelas
                        Jun 6 at 13:52











                        2














                        If you're open to other tools:



                        perl -i -pe 's/(?<!koko)master/kokomaster/' file


                        The (?>!foo) is a negative lookbehind, so (?<!koko)master will only match master when not preceded by koko.






                        share|improve this answer





























                          2














                          If you're open to other tools:



                          perl -i -pe 's/(?<!koko)master/kokomaster/' file


                          The (?>!foo) is a negative lookbehind, so (?<!koko)master will only match master when not preceded by koko.






                          share|improve this answer



























                            2












                            2








                            2







                            If you're open to other tools:



                            perl -i -pe 's/(?<!koko)master/kokomaster/' file


                            The (?>!foo) is a negative lookbehind, so (?<!koko)master will only match master when not preceded by koko.






                            share|improve this answer















                            If you're open to other tools:



                            perl -i -pe 's/(?<!koko)master/kokomaster/' file


                            The (?>!foo) is a negative lookbehind, so (?<!koko)master will only match master when not preceded by koko.







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Jun 6 at 14:56

























                            answered Jun 6 at 13:32









                            terdonterdon

                            137k33 gold badges283 silver badges459 bronze badges




                            137k33 gold badges283 silver badges459 bronze badges





















                                2














                                I have used below awk command to do the same



                                command



                                awk '$0 !~/kokomaster/gsub("master","kokomaster",$0)1' filename >file_tmp && mv file_tmp filename


                                output



                                discovery.uri=http://kokomaster.navada.com:8800
                                discovery.uri=http://kokomaster.navada.com:8800





                                share|improve this answer



























                                  2














                                  I have used below awk command to do the same



                                  command



                                  awk '$0 !~/kokomaster/gsub("master","kokomaster",$0)1' filename >file_tmp && mv file_tmp filename


                                  output



                                  discovery.uri=http://kokomaster.navada.com:8800
                                  discovery.uri=http://kokomaster.navada.com:8800





                                  share|improve this answer

























                                    2












                                    2








                                    2







                                    I have used below awk command to do the same



                                    command



                                    awk '$0 !~/kokomaster/gsub("master","kokomaster",$0)1' filename >file_tmp && mv file_tmp filename


                                    output



                                    discovery.uri=http://kokomaster.navada.com:8800
                                    discovery.uri=http://kokomaster.navada.com:8800





                                    share|improve this answer













                                    I have used below awk command to do the same



                                    command



                                    awk '$0 !~/kokomaster/gsub("master","kokomaster",$0)1' filename >file_tmp && mv file_tmp filename


                                    output



                                    discovery.uri=http://kokomaster.navada.com:8800
                                    discovery.uri=http://kokomaster.navada.com:8800






                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Jun 6 at 15:20









                                    Praveen Kumar BSPraveen Kumar BS

                                    2,1302 gold badges3 silver badges11 bronze badges




                                    2,1302 gold badges3 silver badges11 bronze badges



























                                        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%2f523302%2fsed-add-word-before-string-only-if-not-exists%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

                                        Club Baloncesto Breogán Índice Historia | Pavillón | Nome | O Breogán na cultura popular | Xogadores | Adestradores | Presidentes | Palmarés | Historial | Líderes | Notas | Véxase tamén | Menú de navegacióncbbreogan.galCadroGuía oficial da ACB 2009-10, páxina 201Guía oficial ACB 1992, páxina 183. Editorial DB.É de 6.500 espectadores sentados axeitándose á última normativa"Estudiantes Junior, entre as mellores canteiras"o orixinalHemeroteca El Mundo Deportivo, 16 setembro de 1970, páxina 12Historia do BreogánAlfredo Pérez, o último canoneiroHistoria C.B. BreogánHemeroteca de El Mundo DeportivoJimmy Wright, norteamericano do Breogán deixará Lugo por ameazas de morteResultados de Breogán en 1986-87Resultados de Breogán en 1990-91Ficha de Velimir Perasović en acb.comResultados de Breogán en 1994-95Breogán arrasa al Barça. "El Mundo Deportivo", 27 de setembro de 1999, páxina 58CB Breogán - FC BarcelonaA FEB invita a participar nunha nova Liga EuropeaCharlie Bell na prensa estatalMáximos anotadores 2005Tempada 2005-06 : Tódolos Xogadores da Xornada""Non quero pensar nunha man negra, mais pregúntome que está a pasar""o orixinalRaúl López, orgulloso dos xogadores, presume da boa saúde económica do BreogánJulio González confirma que cesa como presidente del BreogánHomenaxe a Lisardo GómezA tempada do rexurdimento celesteEntrevista a Lisardo GómezEl COB dinamita el Pazo para forzar el quinto (69-73)Cafés Candelas, patrocinador del CB Breogán"Suso Lázare, novo presidente do Breogán"o orixinalCafés Candelas Breogán firma el mayor triunfo de la historiaEl Breogán realizará 17 homenajes por su cincuenta aniversario"O Breogán honra ao seu fundador e primeiro presidente"o orixinalMiguel Giao recibiu a homenaxe do PazoHomenaxe aos primeiros gladiadores celestesO home que nos amosa como ver o Breo co corazónTita Franco será homenaxeada polos #50anosdeBreoJulio Vila recibirá unha homenaxe in memoriam polos #50anosdeBreo"O Breogán homenaxeará aos seus aboados máis veteráns"Pechada ovación a «Capi» Sanmartín e Ricardo «Corazón de González»Homenaxe por décadas de informaciónPaco García volve ao Pazo con motivo do 50 aniversario"Resultados y clasificaciones""O Cafés Candelas Breogán, campión da Copa Princesa""O Cafés Candelas Breogán, equipo ACB"C.B. Breogán"Proxecto social"o orixinal"Centros asociados"o orixinalFicha en imdb.comMario Camus trata la recuperación del amor en 'La vieja música', su última película"Páxina web oficial""Club Baloncesto Breogán""C. B. Breogán S.A.D."eehttp://www.fegaba.com

                                        Vilaño, A Laracha Índice Patrimonio | Lugares e parroquias | Véxase tamén | Menú de navegación43°14′52″N 8°36′03″O / 43.24775, -8.60070

                                        Cegueira Índice Epidemioloxía | Deficiencia visual | Tipos de cegueira | Principais causas de cegueira | Tratamento | Técnicas de adaptación e axudas | Vida dos cegos | Primeiros auxilios | Crenzas respecto das persoas cegas | Crenzas das persoas cegas | O neno deficiente visual | Aspectos psicolóxicos da cegueira | Notas | Véxase tamén | Menú de navegación54.054.154.436928256blindnessDicionario da Real Academia GalegaPortal das Palabras"International Standards: Visual Standards — Aspects and Ranges of Vision Loss with Emphasis on Population Surveys.""Visual impairment and blindness""Presentan un plan para previr a cegueira"o orixinalACCDV Associació Catalana de Cecs i Disminuïts Visuals - PMFTrachoma"Effect of gene therapy on visual function in Leber's congenital amaurosis"1844137110.1056/NEJMoa0802268Cans guía - os mellores amigos dos cegosArquivadoEscola de cans guía para cegos en Mortágua, PortugalArquivado"Tecnología para ciegos y deficientes visuales. Recopilación de recursos gratuitos en la Red""Colorino""‘COL.diesis’, escuchar los sonidos del color""COL.diesis: Transforming Colour into Melody and Implementing the Result in a Colour Sensor Device"o orixinal"Sistema de desarrollo de sinestesia color-sonido para invidentes utilizando un protocolo de audio""Enseñanza táctil - geometría y color. Juegos didácticos para niños ciegos y videntes""Sistema Constanz"L'ocupació laboral dels cecs a l'Estat espanyol està pràcticament equiparada a la de les persones amb visió, entrevista amb Pedro ZuritaONCE (Organización Nacional de Cegos de España)Prevención da cegueiraDescrición de deficiencias visuais (Disc@pnet)Braillín, un boneco atractivo para calquera neno, con ou sen discapacidade, que permite familiarizarse co sistema de escritura e lectura brailleAxudas Técnicas36838ID00897494007150-90057129528256DOID:1432HP:0000618D001766C10.597.751.941.162C97109C0155020