Replacing just the first occurence of a character in a line

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












I have a line with thousands of lines like this:



"100K";"0.00001";"10";"0.01"]
"101K";"0.0001";"100";"0.1"]
"102K";"1";"1000";"1"]
"102K";"1";"1000";"1"]
"103K";"0.01";"10000";"10"]
"104K";"0.1";"100000";"100"]
"105K";"1";"1000000";"1000"]
"109K";"0.000001";"1";"1"]
"120K";"0.000012";"12";"12"]


I want to replace the first occurrence of ; in a line with :[



Making these lines equal to



"100K":["0.00001";"10";"0.01"]
"101K":["0.0001";"100";"0.1"]
"102K":["1";"1000";"1"]
"102K":["1";"1000";"1"]
"103K":["0.01";"10000";"10"]
"104K":["0.1";"100000";"100"]
"105K":["1";"1000000";"1000"]
"109K":["0.000001";"1";"1"]
"120K":["0.000012";"12";"12"]


how do I do that with sed or other unix command?










share|improve this question

























    up vote
    2
    down vote

    favorite












    I have a line with thousands of lines like this:



    "100K";"0.00001";"10";"0.01"]
    "101K";"0.0001";"100";"0.1"]
    "102K";"1";"1000";"1"]
    "102K";"1";"1000";"1"]
    "103K";"0.01";"10000";"10"]
    "104K";"0.1";"100000";"100"]
    "105K";"1";"1000000";"1000"]
    "109K";"0.000001";"1";"1"]
    "120K";"0.000012";"12";"12"]


    I want to replace the first occurrence of ; in a line with :[



    Making these lines equal to



    "100K":["0.00001";"10";"0.01"]
    "101K":["0.0001";"100";"0.1"]
    "102K":["1";"1000";"1"]
    "102K":["1";"1000";"1"]
    "103K":["0.01";"10000";"10"]
    "104K":["0.1";"100000";"100"]
    "105K":["1";"1000000";"1000"]
    "109K":["0.000001";"1";"1"]
    "120K":["0.000012";"12";"12"]


    how do I do that with sed or other unix command?










    share|improve this question























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      I have a line with thousands of lines like this:



      "100K";"0.00001";"10";"0.01"]
      "101K";"0.0001";"100";"0.1"]
      "102K";"1";"1000";"1"]
      "102K";"1";"1000";"1"]
      "103K";"0.01";"10000";"10"]
      "104K";"0.1";"100000";"100"]
      "105K";"1";"1000000";"1000"]
      "109K";"0.000001";"1";"1"]
      "120K";"0.000012";"12";"12"]


      I want to replace the first occurrence of ; in a line with :[



      Making these lines equal to



      "100K":["0.00001";"10";"0.01"]
      "101K":["0.0001";"100";"0.1"]
      "102K":["1";"1000";"1"]
      "102K":["1";"1000";"1"]
      "103K":["0.01";"10000";"10"]
      "104K":["0.1";"100000";"100"]
      "105K":["1";"1000000";"1000"]
      "109K":["0.000001";"1";"1"]
      "120K":["0.000012";"12";"12"]


      how do I do that with sed or other unix command?










      share|improve this question













      I have a line with thousands of lines like this:



      "100K";"0.00001";"10";"0.01"]
      "101K";"0.0001";"100";"0.1"]
      "102K";"1";"1000";"1"]
      "102K";"1";"1000";"1"]
      "103K";"0.01";"10000";"10"]
      "104K";"0.1";"100000";"100"]
      "105K";"1";"1000000";"1000"]
      "109K";"0.000001";"1";"1"]
      "120K";"0.000012";"12";"12"]


      I want to replace the first occurrence of ; in a line with :[



      Making these lines equal to



      "100K":["0.00001";"10";"0.01"]
      "101K":["0.0001";"100";"0.1"]
      "102K":["1";"1000";"1"]
      "102K":["1";"1000";"1"]
      "103K":["0.01";"10000";"10"]
      "104K":["0.1";"100000";"100"]
      "105K":["1";"1000000";"1000"]
      "109K":["0.000001";"1";"1"]
      "120K":["0.000012";"12";"12"]


      how do I do that with sed or other unix command?







      awk sed






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 2 hours ago









      SpaceDog

      1,648122851




      1,648122851




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          7
          down vote



          accepted










          sed 's/;/:[/' file

          "100K":["0.00001";"10";"0.01"]
          "101K":["0.0001";"100";"0.1"]
          "102K":["1";"1000";"1"]
          "102K":["1";"1000";"1"]
          "103K":["0.01";"10000";"10"]
          "104K":["0.1";"100000";"100"]
          "105K":["1";"1000000";"1000"]
          "109K":["0.000001";"1";"1"]
          "120K":["0.000012";"12";"12"]





          share|improve this answer
















          • 1




            if you add g to the command above like sed 's/;/:[/g' it will apply global (g stands for global)change meaning it will change every occurrence
            – Goro
            2 hours ago







          • 1




            if you add -i, you do it in one go.
            – Rui F Ribeiro
            2 hours ago










          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',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          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%2f474287%2freplacing-just-the-first-occurence-of-a-character-in-a-line%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          7
          down vote



          accepted










          sed 's/;/:[/' file

          "100K":["0.00001";"10";"0.01"]
          "101K":["0.0001";"100";"0.1"]
          "102K":["1";"1000";"1"]
          "102K":["1";"1000";"1"]
          "103K":["0.01";"10000";"10"]
          "104K":["0.1";"100000";"100"]
          "105K":["1";"1000000";"1000"]
          "109K":["0.000001";"1";"1"]
          "120K":["0.000012";"12";"12"]





          share|improve this answer
















          • 1




            if you add g to the command above like sed 's/;/:[/g' it will apply global (g stands for global)change meaning it will change every occurrence
            – Goro
            2 hours ago







          • 1




            if you add -i, you do it in one go.
            – Rui F Ribeiro
            2 hours ago














          up vote
          7
          down vote



          accepted










          sed 's/;/:[/' file

          "100K":["0.00001";"10";"0.01"]
          "101K":["0.0001";"100";"0.1"]
          "102K":["1";"1000";"1"]
          "102K":["1";"1000";"1"]
          "103K":["0.01";"10000";"10"]
          "104K":["0.1";"100000";"100"]
          "105K":["1";"1000000";"1000"]
          "109K":["0.000001";"1";"1"]
          "120K":["0.000012";"12";"12"]





          share|improve this answer
















          • 1




            if you add g to the command above like sed 's/;/:[/g' it will apply global (g stands for global)change meaning it will change every occurrence
            – Goro
            2 hours ago







          • 1




            if you add -i, you do it in one go.
            – Rui F Ribeiro
            2 hours ago












          up vote
          7
          down vote



          accepted







          up vote
          7
          down vote



          accepted






          sed 's/;/:[/' file

          "100K":["0.00001";"10";"0.01"]
          "101K":["0.0001";"100";"0.1"]
          "102K":["1";"1000";"1"]
          "102K":["1";"1000";"1"]
          "103K":["0.01";"10000";"10"]
          "104K":["0.1";"100000";"100"]
          "105K":["1";"1000000";"1000"]
          "109K":["0.000001";"1";"1"]
          "120K":["0.000012";"12";"12"]





          share|improve this answer












          sed 's/;/:[/' file

          "100K":["0.00001";"10";"0.01"]
          "101K":["0.0001";"100";"0.1"]
          "102K":["1";"1000";"1"]
          "102K":["1";"1000";"1"]
          "103K":["0.01";"10000";"10"]
          "104K":["0.1";"100000";"100"]
          "105K":["1";"1000000";"1000"]
          "109K":["0.000001";"1";"1"]
          "120K":["0.000012";"12";"12"]






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 2 hours ago









          Goro

          7,89653574




          7,89653574







          • 1




            if you add g to the command above like sed 's/;/:[/g' it will apply global (g stands for global)change meaning it will change every occurrence
            – Goro
            2 hours ago







          • 1




            if you add -i, you do it in one go.
            – Rui F Ribeiro
            2 hours ago












          • 1




            if you add g to the command above like sed 's/;/:[/g' it will apply global (g stands for global)change meaning it will change every occurrence
            – Goro
            2 hours ago







          • 1




            if you add -i, you do it in one go.
            – Rui F Ribeiro
            2 hours ago







          1




          1




          if you add g to the command above like sed 's/;/:[/g' it will apply global (g stands for global)change meaning it will change every occurrence
          – Goro
          2 hours ago





          if you add g to the command above like sed 's/;/:[/g' it will apply global (g stands for global)change meaning it will change every occurrence
          – Goro
          2 hours ago





          1




          1




          if you add -i, you do it in one go.
          – Rui F Ribeiro
          2 hours ago




          if you add -i, you do it in one go.
          – Rui F Ribeiro
          2 hours ago

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f474287%2freplacing-just-the-first-occurence-of-a-character-in-a-line%23new-answer', 'question_page');

          );

          Post as a guest













































































          Comments

          Popular posts from this blog

          Long meetings (6-7 hours a day): Being “babysat” by supervisor

          Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

          Confectionery