replacing comma with numbers in a string

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 text file contain strings like this



abc,def,ghi,jkl,mno,pqr,stu,wxyz


I want to make it like this



1.abc
2.def
3.ghi
4.jkl
5.mno
6.pqr
7.stu
8.wxyz


how can i do that using sed?










share|improve this question







New contributor




Kevin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.























    up vote
    2
    down vote

    favorite












    I have text file contain strings like this



    abc,def,ghi,jkl,mno,pqr,stu,wxyz


    I want to make it like this



    1.abc
    2.def
    3.ghi
    4.jkl
    5.mno
    6.pqr
    7.stu
    8.wxyz


    how can i do that using sed?










    share|improve this question







    New contributor




    Kevin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      I have text file contain strings like this



      abc,def,ghi,jkl,mno,pqr,stu,wxyz


      I want to make it like this



      1.abc
      2.def
      3.ghi
      4.jkl
      5.mno
      6.pqr
      7.stu
      8.wxyz


      how can i do that using sed?










      share|improve this question







      New contributor




      Kevin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      I have text file contain strings like this



      abc,def,ghi,jkl,mno,pqr,stu,wxyz


      I want to make it like this



      1.abc
      2.def
      3.ghi
      4.jkl
      5.mno
      6.pqr
      7.stu
      8.wxyz


      how can i do that using sed?







      sed






      share|improve this question







      New contributor




      Kevin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      Kevin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      Kevin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 33 mins ago









      Kevin

      415




      415




      New contributor




      Kevin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Kevin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Kevin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          You can do this



          echo abc,def,ghi,jkl,mno,pqr,stu,wxyz | sed 's/,/n/g' | nl -s "."

          1.abc
          2.def
          3.ghi
          4.jkl
          5.mno
          6.pqr
          7.stu
          8.wxyz





          share|improve this answer
















          • 2




            cool +1. Didn't know about nl. Add -w 1 to nl to get the desired output.
            – RoVo
            22 mins ago


















          up vote
          1
          down vote













          You can use GNU awk:



          awk -v RS=',|n' 'printf "%s.%sn",NR,$0' <<< "abc,def,ghi,jkl,mno,pqr,stu,wxyz"





          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',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );






            Kevin is a new contributor. Be nice, and check out our Code of Conduct.









             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f474441%2freplacing-comma-with-numbers-in-a-string%23new-answer', 'question_page');

            );

            Post as a guest






























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            2
            down vote



            accepted










            You can do this



            echo abc,def,ghi,jkl,mno,pqr,stu,wxyz | sed 's/,/n/g' | nl -s "."

            1.abc
            2.def
            3.ghi
            4.jkl
            5.mno
            6.pqr
            7.stu
            8.wxyz





            share|improve this answer
















            • 2




              cool +1. Didn't know about nl. Add -w 1 to nl to get the desired output.
              – RoVo
              22 mins ago















            up vote
            2
            down vote



            accepted










            You can do this



            echo abc,def,ghi,jkl,mno,pqr,stu,wxyz | sed 's/,/n/g' | nl -s "."

            1.abc
            2.def
            3.ghi
            4.jkl
            5.mno
            6.pqr
            7.stu
            8.wxyz





            share|improve this answer
















            • 2




              cool +1. Didn't know about nl. Add -w 1 to nl to get the desired output.
              – RoVo
              22 mins ago













            up vote
            2
            down vote



            accepted







            up vote
            2
            down vote



            accepted






            You can do this



            echo abc,def,ghi,jkl,mno,pqr,stu,wxyz | sed 's/,/n/g' | nl -s "."

            1.abc
            2.def
            3.ghi
            4.jkl
            5.mno
            6.pqr
            7.stu
            8.wxyz





            share|improve this answer












            You can do this



            echo abc,def,ghi,jkl,mno,pqr,stu,wxyz | sed 's/,/n/g' | nl -s "."

            1.abc
            2.def
            3.ghi
            4.jkl
            5.mno
            6.pqr
            7.stu
            8.wxyz






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 30 mins ago









            Goro

            8,15253980




            8,15253980







            • 2




              cool +1. Didn't know about nl. Add -w 1 to nl to get the desired output.
              – RoVo
              22 mins ago













            • 2




              cool +1. Didn't know about nl. Add -w 1 to nl to get the desired output.
              – RoVo
              22 mins ago








            2




            2




            cool +1. Didn't know about nl. Add -w 1 to nl to get the desired output.
            – RoVo
            22 mins ago





            cool +1. Didn't know about nl. Add -w 1 to nl to get the desired output.
            – RoVo
            22 mins ago













            up vote
            1
            down vote













            You can use GNU awk:



            awk -v RS=',|n' 'printf "%s.%sn",NR,$0' <<< "abc,def,ghi,jkl,mno,pqr,stu,wxyz"





            share|improve this answer
























              up vote
              1
              down vote













              You can use GNU awk:



              awk -v RS=',|n' 'printf "%s.%sn",NR,$0' <<< "abc,def,ghi,jkl,mno,pqr,stu,wxyz"





              share|improve this answer






















                up vote
                1
                down vote










                up vote
                1
                down vote









                You can use GNU awk:



                awk -v RS=',|n' 'printf "%s.%sn",NR,$0' <<< "abc,def,ghi,jkl,mno,pqr,stu,wxyz"





                share|improve this answer












                You can use GNU awk:



                awk -v RS=',|n' 'printf "%s.%sn",NR,$0' <<< "abc,def,ghi,jkl,mno,pqr,stu,wxyz"






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 24 mins ago









                oliv

                1,186210




                1,186210




















                    Kevin is a new contributor. Be nice, and check out our Code of Conduct.









                     

                    draft saved


                    draft discarded


















                    Kevin is a new contributor. Be nice, and check out our Code of Conduct.












                    Kevin is a new contributor. Be nice, and check out our Code of Conduct.











                    Kevin is a new contributor. Be nice, and check out our Code of Conduct.













                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f474441%2freplacing-comma-with-numbers-in-a-string%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    What does second last employer means? [closed]

                    List of Gilmore Girls characters

                    Confectionery