How can I add lines to document every four lines?

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











up vote
4
down vote

favorite












I want to add a new line every four lines of a document.



For example:



abc
def
ghi
jkl
mno
pqr
stu
vw
xyz


should become:



abc
def
ghi
jkl

mno
pqr
stu
vw

xyz









share|improve this question









New contributor




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























    up vote
    4
    down vote

    favorite












    I want to add a new line every four lines of a document.



    For example:



    abc
    def
    ghi
    jkl
    mno
    pqr
    stu
    vw
    xyz


    should become:



    abc
    def
    ghi
    jkl

    mno
    pqr
    stu
    vw

    xyz









    share|improve this question









    New contributor




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





















      up vote
      4
      down vote

      favorite









      up vote
      4
      down vote

      favorite











      I want to add a new line every four lines of a document.



      For example:



      abc
      def
      ghi
      jkl
      mno
      pqr
      stu
      vw
      xyz


      should become:



      abc
      def
      ghi
      jkl

      mno
      pqr
      stu
      vw

      xyz









      share|improve this question









      New contributor




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











      I want to add a new line every four lines of a document.



      For example:



      abc
      def
      ghi
      jkl
      mno
      pqr
      stu
      vw
      xyz


      should become:



      abc
      def
      ghi
      jkl

      mno
      pqr
      stu
      vw

      xyz






      text-processing






      share|improve this question









      New contributor




      Advil 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




      Advil 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








      edited 5 mins ago









      Isaac

      7,89711137




      7,89711137






      New contributor




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









      asked 40 mins ago









      Advil

      211




      211




      New contributor




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





      New contributor





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






      Advil 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
          3
          down vote













          try this command:



          awk ' print; NR % 4 == 0 print ""; '





          share|improve this answer



























            up vote
            2
            down vote













            With (GNU) sed:



            sed '0~4G'


            man sed explains ~ as:




            first ~ step

            Match every step'th line starting with line first. For example, ``sed -n 1~2p'' will print all the odd-numbered lines in the input stream, and the address 2~5 will match every fifth line, starting with the second. first can be zero; in this case, sed operates as if it were equal to step. (This is an extension.)




            With awk, probably:



            awk '1 ; NR%4==0 printf"n" '





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



              );






              Advil 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%2f474172%2fhow-can-i-add-lines-to-document-every-four-lines%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
              3
              down vote













              try this command:



              awk ' print; NR % 4 == 0 print ""; '





              share|improve this answer
























                up vote
                3
                down vote













                try this command:



                awk ' print; NR % 4 == 0 print ""; '





                share|improve this answer






















                  up vote
                  3
                  down vote










                  up vote
                  3
                  down vote









                  try this command:



                  awk ' print; NR % 4 == 0 print ""; '





                  share|improve this answer












                  try this command:



                  awk ' print; NR % 4 == 0 print ""; '






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 37 mins ago









                  Goro

                  7,72753371




                  7,72753371






















                      up vote
                      2
                      down vote













                      With (GNU) sed:



                      sed '0~4G'


                      man sed explains ~ as:




                      first ~ step

                      Match every step'th line starting with line first. For example, ``sed -n 1~2p'' will print all the odd-numbered lines in the input stream, and the address 2~5 will match every fifth line, starting with the second. first can be zero; in this case, sed operates as if it were equal to step. (This is an extension.)




                      With awk, probably:



                      awk '1 ; NR%4==0 printf"n" '





                      share|improve this answer


























                        up vote
                        2
                        down vote













                        With (GNU) sed:



                        sed '0~4G'


                        man sed explains ~ as:




                        first ~ step

                        Match every step'th line starting with line first. For example, ``sed -n 1~2p'' will print all the odd-numbered lines in the input stream, and the address 2~5 will match every fifth line, starting with the second. first can be zero; in this case, sed operates as if it were equal to step. (This is an extension.)




                        With awk, probably:



                        awk '1 ; NR%4==0 printf"n" '





                        share|improve this answer
























                          up vote
                          2
                          down vote










                          up vote
                          2
                          down vote









                          With (GNU) sed:



                          sed '0~4G'


                          man sed explains ~ as:




                          first ~ step

                          Match every step'th line starting with line first. For example, ``sed -n 1~2p'' will print all the odd-numbered lines in the input stream, and the address 2~5 will match every fifth line, starting with the second. first can be zero; in this case, sed operates as if it were equal to step. (This is an extension.)




                          With awk, probably:



                          awk '1 ; NR%4==0 printf"n" '





                          share|improve this answer














                          With (GNU) sed:



                          sed '0~4G'


                          man sed explains ~ as:




                          first ~ step

                          Match every step'th line starting with line first. For example, ``sed -n 1~2p'' will print all the odd-numbered lines in the input stream, and the address 2~5 will match every fifth line, starting with the second. first can be zero; in this case, sed operates as if it were equal to step. (This is an extension.)




                          With awk, probably:



                          awk '1 ; NR%4==0 printf"n" '






                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited 4 mins ago

























                          answered 31 mins ago









                          Isaac

                          7,89711137




                          7,89711137




















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









                               

                              draft saved


                              draft discarded


















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












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











                              Advil 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%2f474172%2fhow-can-i-add-lines-to-document-every-four-lines%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