How to remove n from a column using awk or sed

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











up vote
1
down vote

favorite












I have data:



1528198031|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
1528202225|Andr|thund|Lorem ipsum dolor sit amet, conse
1) Lorem ipsum dolor sit amet, consectetur adipiscing elit
2) Lorem ipsum dolor sit amet, consectetur adipiscing elit
3) Lorem ipsum dolor sit amet, consectetur adipiscing elit

Lorem ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elit
1528202574|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
1528203825|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
1528203890|Andr|rail|Lorem ipsum dolor sit amet, consectetur adipiscing elit


I want to remove n in column 4 using sed or awk if it possible. Result would look like this:



1528198031|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
1528202225|Andr|thund|Lorem ipsum dolor sit amet, conse 1) Lorem ipsum dolor sit amet, consectetur adipiscing elit 2) Lorem ipsum dolor sit amet, consectetur adipiscing elit 3) Lorem ipsum dolor sit amet, consectetur adipiscing elit Lorem ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elit
1528202574|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
1528203825|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
1528203890|Andr|rail|Lorem ipsum dolor sit amet, consectetur adipiscing elit


Patterns before n always different, it can be 1-9 or text, or symbols like :,;, (, ).



Text was changed, but formatting is like in original data.







share|improve this question























    up vote
    1
    down vote

    favorite












    I have data:



    1528198031|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
    1528202225|Andr|thund|Lorem ipsum dolor sit amet, conse
    1) Lorem ipsum dolor sit amet, consectetur adipiscing elit
    2) Lorem ipsum dolor sit amet, consectetur adipiscing elit
    3) Lorem ipsum dolor sit amet, consectetur adipiscing elit

    Lorem ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elit
    1528202574|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
    1528203825|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
    1528203890|Andr|rail|Lorem ipsum dolor sit amet, consectetur adipiscing elit


    I want to remove n in column 4 using sed or awk if it possible. Result would look like this:



    1528198031|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
    1528202225|Andr|thund|Lorem ipsum dolor sit amet, conse 1) Lorem ipsum dolor sit amet, consectetur adipiscing elit 2) Lorem ipsum dolor sit amet, consectetur adipiscing elit 3) Lorem ipsum dolor sit amet, consectetur adipiscing elit Lorem ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elit
    1528202574|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
    1528203825|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
    1528203890|Andr|rail|Lorem ipsum dolor sit amet, consectetur adipiscing elit


    Patterns before n always different, it can be 1-9 or text, or symbols like :,;, (, ).



    Text was changed, but formatting is like in original data.







    share|improve this question





















      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I have data:



      1528198031|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
      1528202225|Andr|thund|Lorem ipsum dolor sit amet, conse
      1) Lorem ipsum dolor sit amet, consectetur adipiscing elit
      2) Lorem ipsum dolor sit amet, consectetur adipiscing elit
      3) Lorem ipsum dolor sit amet, consectetur adipiscing elit

      Lorem ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elit
      1528202574|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
      1528203825|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
      1528203890|Andr|rail|Lorem ipsum dolor sit amet, consectetur adipiscing elit


      I want to remove n in column 4 using sed or awk if it possible. Result would look like this:



      1528198031|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
      1528202225|Andr|thund|Lorem ipsum dolor sit amet, conse 1) Lorem ipsum dolor sit amet, consectetur adipiscing elit 2) Lorem ipsum dolor sit amet, consectetur adipiscing elit 3) Lorem ipsum dolor sit amet, consectetur adipiscing elit Lorem ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elit
      1528202574|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
      1528203825|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
      1528203890|Andr|rail|Lorem ipsum dolor sit amet, consectetur adipiscing elit


      Patterns before n always different, it can be 1-9 or text, or symbols like :,;, (, ).



      Text was changed, but formatting is like in original data.







      share|improve this question











      I have data:



      1528198031|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
      1528202225|Andr|thund|Lorem ipsum dolor sit amet, conse
      1) Lorem ipsum dolor sit amet, consectetur adipiscing elit
      2) Lorem ipsum dolor sit amet, consectetur adipiscing elit
      3) Lorem ipsum dolor sit amet, consectetur adipiscing elit

      Lorem ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elit
      1528202574|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
      1528203825|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
      1528203890|Andr|rail|Lorem ipsum dolor sit amet, consectetur adipiscing elit


      I want to remove n in column 4 using sed or awk if it possible. Result would look like this:



      1528198031|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
      1528202225|Andr|thund|Lorem ipsum dolor sit amet, conse 1) Lorem ipsum dolor sit amet, consectetur adipiscing elit 2) Lorem ipsum dolor sit amet, consectetur adipiscing elit 3) Lorem ipsum dolor sit amet, consectetur adipiscing elit Lorem ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elit
      1528202574|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
      1528203825|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
      1528203890|Andr|rail|Lorem ipsum dolor sit amet, consectetur adipiscing elit


      Patterns before n always different, it can be 1-9 or text, or symbols like :,;, (, ).



      Text was changed, but formatting is like in original data.









      share|improve this question










      share|improve this question




      share|improve this question









      asked Jun 13 at 19:11









      Strawberry Hat

      113




      113




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          sed - join to the previous line if this line contains only non-pipe characters:



          sed -e :a -e '$!N; s/n([^|]*)$/ 1/; ta' -e 'P;D' file
          1528198031|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
          1528202225|Andr|thund|Lorem ipsum dolor sit amet, conse 1) Lorem ipsum dolor sit amet, consectetur adipiscing elit 2) Lorem ipsum dolor sit amet, consectetur adipiscing elit 3) Lorem ipsum dolor sit amet, consectetur adipiscing elit Lorem ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elit
          1528202574|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
          1528203825|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
          1528203890|Andr|rail|Lorem ipsum dolor sit amet, consectetur adipiscing elit





          share|improve this answer





















          • Yeah, that's it. But I don't know why, it doesn't work with file, unless I open it and save manually. Then it works perfect.
            – Strawberry Hat
            Jun 13 at 20:52










          • @StrawberryHat your version of sed may have a -i or --in-place option that allows you to modify the contents of the file directly
            – steeldriver
            Jun 13 at 22:10










          • tried with -i, still don't work without manually saving file. Tried to split file by 250 lines, change chmod - also doesn't work. upd: Sed version 4.5 March 2018 (that's how man sed print it)
            – Strawberry Hat
            Jun 13 at 22:33











          • @StrawberryHat perhaps the original file contains non-printing characters that are getting stripped out when you re-save the file? The usual culprits are carriage returns (from DOS-style CRLF line endings)
            – steeldriver
            Jun 13 at 23:13











          • Yeah, you right! Added -e 's/r//g' before your first -e and it's working now. Thank you!
            – Strawberry Hat
            Jun 14 at 0:12

















          up vote
          0
          down vote













          Awk solution:



          awk -F'|' ' printf "%s%s", (NR == 1? "" : (NF > 1? ORS : OFS)), $0 
          END print "" ' file


          The output:



          1528198031|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
          1528202225|Andr|thund|Lorem ipsum dolor sit amet, conse 1) Lorem ipsum dolor sit amet, consectetur adipiscing elit 2) Lorem ipsum dolor sit amet, consectetur adipiscing elit 3) Lorem ipsum dolor sit amet, consectetur adipiscing elit Lorem ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elit
          1528202574|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
          1528203825|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
          1528203890|Andr|rail|Lorem ipsum dolor sit amet, consectetur adipiscing elit





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



            );








             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f449637%2fhow-to-remove-n-from-a-column-using-awk-or-sed%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










            sed - join to the previous line if this line contains only non-pipe characters:



            sed -e :a -e '$!N; s/n([^|]*)$/ 1/; ta' -e 'P;D' file
            1528198031|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
            1528202225|Andr|thund|Lorem ipsum dolor sit amet, conse 1) Lorem ipsum dolor sit amet, consectetur adipiscing elit 2) Lorem ipsum dolor sit amet, consectetur adipiscing elit 3) Lorem ipsum dolor sit amet, consectetur adipiscing elit Lorem ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elit
            1528202574|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
            1528203825|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
            1528203890|Andr|rail|Lorem ipsum dolor sit amet, consectetur adipiscing elit





            share|improve this answer





















            • Yeah, that's it. But I don't know why, it doesn't work with file, unless I open it and save manually. Then it works perfect.
              – Strawberry Hat
              Jun 13 at 20:52










            • @StrawberryHat your version of sed may have a -i or --in-place option that allows you to modify the contents of the file directly
              – steeldriver
              Jun 13 at 22:10










            • tried with -i, still don't work without manually saving file. Tried to split file by 250 lines, change chmod - also doesn't work. upd: Sed version 4.5 March 2018 (that's how man sed print it)
              – Strawberry Hat
              Jun 13 at 22:33











            • @StrawberryHat perhaps the original file contains non-printing characters that are getting stripped out when you re-save the file? The usual culprits are carriage returns (from DOS-style CRLF line endings)
              – steeldriver
              Jun 13 at 23:13











            • Yeah, you right! Added -e 's/r//g' before your first -e and it's working now. Thank you!
              – Strawberry Hat
              Jun 14 at 0:12














            up vote
            2
            down vote



            accepted










            sed - join to the previous line if this line contains only non-pipe characters:



            sed -e :a -e '$!N; s/n([^|]*)$/ 1/; ta' -e 'P;D' file
            1528198031|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
            1528202225|Andr|thund|Lorem ipsum dolor sit amet, conse 1) Lorem ipsum dolor sit amet, consectetur adipiscing elit 2) Lorem ipsum dolor sit amet, consectetur adipiscing elit 3) Lorem ipsum dolor sit amet, consectetur adipiscing elit Lorem ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elit
            1528202574|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
            1528203825|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
            1528203890|Andr|rail|Lorem ipsum dolor sit amet, consectetur adipiscing elit





            share|improve this answer





















            • Yeah, that's it. But I don't know why, it doesn't work with file, unless I open it and save manually. Then it works perfect.
              – Strawberry Hat
              Jun 13 at 20:52










            • @StrawberryHat your version of sed may have a -i or --in-place option that allows you to modify the contents of the file directly
              – steeldriver
              Jun 13 at 22:10










            • tried with -i, still don't work without manually saving file. Tried to split file by 250 lines, change chmod - also doesn't work. upd: Sed version 4.5 March 2018 (that's how man sed print it)
              – Strawberry Hat
              Jun 13 at 22:33











            • @StrawberryHat perhaps the original file contains non-printing characters that are getting stripped out when you re-save the file? The usual culprits are carriage returns (from DOS-style CRLF line endings)
              – steeldriver
              Jun 13 at 23:13











            • Yeah, you right! Added -e 's/r//g' before your first -e and it's working now. Thank you!
              – Strawberry Hat
              Jun 14 at 0:12












            up vote
            2
            down vote



            accepted







            up vote
            2
            down vote



            accepted






            sed - join to the previous line if this line contains only non-pipe characters:



            sed -e :a -e '$!N; s/n([^|]*)$/ 1/; ta' -e 'P;D' file
            1528198031|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
            1528202225|Andr|thund|Lorem ipsum dolor sit amet, conse 1) Lorem ipsum dolor sit amet, consectetur adipiscing elit 2) Lorem ipsum dolor sit amet, consectetur adipiscing elit 3) Lorem ipsum dolor sit amet, consectetur adipiscing elit Lorem ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elit
            1528202574|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
            1528203825|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
            1528203890|Andr|rail|Lorem ipsum dolor sit amet, consectetur adipiscing elit





            share|improve this answer













            sed - join to the previous line if this line contains only non-pipe characters:



            sed -e :a -e '$!N; s/n([^|]*)$/ 1/; ta' -e 'P;D' file
            1528198031|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
            1528202225|Andr|thund|Lorem ipsum dolor sit amet, conse 1) Lorem ipsum dolor sit amet, consectetur adipiscing elit 2) Lorem ipsum dolor sit amet, consectetur adipiscing elit 3) Lorem ipsum dolor sit amet, consectetur adipiscing elit Lorem ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elit
            1528202574|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
            1528203825|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
            1528203890|Andr|rail|Lorem ipsum dolor sit amet, consectetur adipiscing elit






            share|improve this answer













            share|improve this answer



            share|improve this answer











            answered Jun 13 at 19:39









            steeldriver

            30.9k34877




            30.9k34877











            • Yeah, that's it. But I don't know why, it doesn't work with file, unless I open it and save manually. Then it works perfect.
              – Strawberry Hat
              Jun 13 at 20:52










            • @StrawberryHat your version of sed may have a -i or --in-place option that allows you to modify the contents of the file directly
              – steeldriver
              Jun 13 at 22:10










            • tried with -i, still don't work without manually saving file. Tried to split file by 250 lines, change chmod - also doesn't work. upd: Sed version 4.5 March 2018 (that's how man sed print it)
              – Strawberry Hat
              Jun 13 at 22:33











            • @StrawberryHat perhaps the original file contains non-printing characters that are getting stripped out when you re-save the file? The usual culprits are carriage returns (from DOS-style CRLF line endings)
              – steeldriver
              Jun 13 at 23:13











            • Yeah, you right! Added -e 's/r//g' before your first -e and it's working now. Thank you!
              – Strawberry Hat
              Jun 14 at 0:12
















            • Yeah, that's it. But I don't know why, it doesn't work with file, unless I open it and save manually. Then it works perfect.
              – Strawberry Hat
              Jun 13 at 20:52










            • @StrawberryHat your version of sed may have a -i or --in-place option that allows you to modify the contents of the file directly
              – steeldriver
              Jun 13 at 22:10










            • tried with -i, still don't work without manually saving file. Tried to split file by 250 lines, change chmod - also doesn't work. upd: Sed version 4.5 March 2018 (that's how man sed print it)
              – Strawberry Hat
              Jun 13 at 22:33











            • @StrawberryHat perhaps the original file contains non-printing characters that are getting stripped out when you re-save the file? The usual culprits are carriage returns (from DOS-style CRLF line endings)
              – steeldriver
              Jun 13 at 23:13











            • Yeah, you right! Added -e 's/r//g' before your first -e and it's working now. Thank you!
              – Strawberry Hat
              Jun 14 at 0:12















            Yeah, that's it. But I don't know why, it doesn't work with file, unless I open it and save manually. Then it works perfect.
            – Strawberry Hat
            Jun 13 at 20:52




            Yeah, that's it. But I don't know why, it doesn't work with file, unless I open it and save manually. Then it works perfect.
            – Strawberry Hat
            Jun 13 at 20:52












            @StrawberryHat your version of sed may have a -i or --in-place option that allows you to modify the contents of the file directly
            – steeldriver
            Jun 13 at 22:10




            @StrawberryHat your version of sed may have a -i or --in-place option that allows you to modify the contents of the file directly
            – steeldriver
            Jun 13 at 22:10












            tried with -i, still don't work without manually saving file. Tried to split file by 250 lines, change chmod - also doesn't work. upd: Sed version 4.5 March 2018 (that's how man sed print it)
            – Strawberry Hat
            Jun 13 at 22:33





            tried with -i, still don't work without manually saving file. Tried to split file by 250 lines, change chmod - also doesn't work. upd: Sed version 4.5 March 2018 (that's how man sed print it)
            – Strawberry Hat
            Jun 13 at 22:33













            @StrawberryHat perhaps the original file contains non-printing characters that are getting stripped out when you re-save the file? The usual culprits are carriage returns (from DOS-style CRLF line endings)
            – steeldriver
            Jun 13 at 23:13





            @StrawberryHat perhaps the original file contains non-printing characters that are getting stripped out when you re-save the file? The usual culprits are carriage returns (from DOS-style CRLF line endings)
            – steeldriver
            Jun 13 at 23:13













            Yeah, you right! Added -e 's/r//g' before your first -e and it's working now. Thank you!
            – Strawberry Hat
            Jun 14 at 0:12




            Yeah, you right! Added -e 's/r//g' before your first -e and it's working now. Thank you!
            – Strawberry Hat
            Jun 14 at 0:12












            up vote
            0
            down vote













            Awk solution:



            awk -F'|' ' printf "%s%s", (NR == 1? "" : (NF > 1? ORS : OFS)), $0 
            END print "" ' file


            The output:



            1528198031|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
            1528202225|Andr|thund|Lorem ipsum dolor sit amet, conse 1) Lorem ipsum dolor sit amet, consectetur adipiscing elit 2) Lorem ipsum dolor sit amet, consectetur adipiscing elit 3) Lorem ipsum dolor sit amet, consectetur adipiscing elit Lorem ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elit
            1528202574|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
            1528203825|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
            1528203890|Andr|rail|Lorem ipsum dolor sit amet, consectetur adipiscing elit





            share|improve this answer

























              up vote
              0
              down vote













              Awk solution:



              awk -F'|' ' printf "%s%s", (NR == 1? "" : (NF > 1? ORS : OFS)), $0 
              END print "" ' file


              The output:



              1528198031|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
              1528202225|Andr|thund|Lorem ipsum dolor sit amet, conse 1) Lorem ipsum dolor sit amet, consectetur adipiscing elit 2) Lorem ipsum dolor sit amet, consectetur adipiscing elit 3) Lorem ipsum dolor sit amet, consectetur adipiscing elit Lorem ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elit
              1528202574|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
              1528203825|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
              1528203890|Andr|rail|Lorem ipsum dolor sit amet, consectetur adipiscing elit





              share|improve this answer























                up vote
                0
                down vote










                up vote
                0
                down vote









                Awk solution:



                awk -F'|' ' printf "%s%s", (NR == 1? "" : (NF > 1? ORS : OFS)), $0 
                END print "" ' file


                The output:



                1528198031|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
                1528202225|Andr|thund|Lorem ipsum dolor sit amet, conse 1) Lorem ipsum dolor sit amet, consectetur adipiscing elit 2) Lorem ipsum dolor sit amet, consectetur adipiscing elit 3) Lorem ipsum dolor sit amet, consectetur adipiscing elit Lorem ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elit
                1528202574|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
                1528203825|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
                1528203890|Andr|rail|Lorem ipsum dolor sit amet, consectetur adipiscing elit





                share|improve this answer













                Awk solution:



                awk -F'|' ' printf "%s%s", (NR == 1? "" : (NF > 1? ORS : OFS)), $0 
                END print "" ' file


                The output:



                1528198031|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
                1528202225|Andr|thund|Lorem ipsum dolor sit amet, conse 1) Lorem ipsum dolor sit amet, consectetur adipiscing elit 2) Lorem ipsum dolor sit amet, consectetur adipiscing elit 3) Lorem ipsum dolor sit amet, consectetur adipiscing elit Lorem ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elit
                1528202574|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
                1528203825|Andr|thund|Lorem ipsum dolor sit amet, consectetur adipiscing elit
                1528203890|Andr|rail|Lorem ipsum dolor sit amet, consectetur adipiscing elit






                share|improve this answer













                share|improve this answer



                share|improve this answer











                answered Jun 13 at 19:33









                RomanPerekhrest

                22.4k12144




                22.4k12144






















                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f449637%2fhow-to-remove-n-from-a-column-using-awk-or-sed%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Displaying single band from multi-band raster using QGIS

                    How many registers does an x86_64 CPU actually have?