Combine multiple text files into one file












7














I am using the unix pr command to combine multiple text files into one text file:



pr -F *files > newfile


Each file is a different length, a different number of lines. I am mostly happy with the result, I like that it includes the name of the original text file followed by the contents of that file. However, I would like to eliminate the blank lines in between the name of the original text file and it's contents. I only want blank lines between the different text files to separate each. Also, it prints the character ^L after the contents of each text file, and I would like to eliminate that character.



Each file read in is also given a 'page' number. Only one file is longer than the 66 line default. that file ends up being spit into 2 'pages', and is split into 2 sections divided by blank lines. Is it possible to write that text in continuously without it being split?



Thank you for any help!










share|improve this question





























    7














    I am using the unix pr command to combine multiple text files into one text file:



    pr -F *files > newfile


    Each file is a different length, a different number of lines. I am mostly happy with the result, I like that it includes the name of the original text file followed by the contents of that file. However, I would like to eliminate the blank lines in between the name of the original text file and it's contents. I only want blank lines between the different text files to separate each. Also, it prints the character ^L after the contents of each text file, and I would like to eliminate that character.



    Each file read in is also given a 'page' number. Only one file is longer than the 66 line default. that file ends up being spit into 2 'pages', and is split into 2 sections divided by blank lines. Is it possible to write that text in continuously without it being split?



    Thank you for any help!










    share|improve this question



























      7












      7








      7


      1





      I am using the unix pr command to combine multiple text files into one text file:



      pr -F *files > newfile


      Each file is a different length, a different number of lines. I am mostly happy with the result, I like that it includes the name of the original text file followed by the contents of that file. However, I would like to eliminate the blank lines in between the name of the original text file and it's contents. I only want blank lines between the different text files to separate each. Also, it prints the character ^L after the contents of each text file, and I would like to eliminate that character.



      Each file read in is also given a 'page' number. Only one file is longer than the 66 line default. that file ends up being spit into 2 'pages', and is split into 2 sections divided by blank lines. Is it possible to write that text in continuously without it being split?



      Thank you for any help!










      share|improve this question















      I am using the unix pr command to combine multiple text files into one text file:



      pr -F *files > newfile


      Each file is a different length, a different number of lines. I am mostly happy with the result, I like that it includes the name of the original text file followed by the contents of that file. However, I would like to eliminate the blank lines in between the name of the original text file and it's contents. I only want blank lines between the different text files to separate each. Also, it prints the character ^L after the contents of each text file, and I would like to eliminate that character.



      Each file read in is also given a 'page' number. Only one file is longer than the 66 line default. that file ends up being spit into 2 'pages', and is split into 2 sections divided by blank lines. Is it possible to write that text in continuously without it being split?



      Thank you for any help!







      command-line






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jul 11 '13 at 5:34









      Radu Rădeanu

      116k34247323




      116k34247323










      asked Jul 11 '13 at 4:38









      janetjanet

      169227




      169227






















          4 Answers
          4






          active

          oldest

          votes


















          8














          You can use the AWK utility:



          awk 'FNR==1{print ""}{print}' *files > newfile


          Source: https://stackoverflow.com/questions/1653063/how-do-i-include-a-blank-line-between-files-im-concatenating-with-cat






          share|improve this answer























          • thank you for you suggestion. however, -T isn't being recognized. i'm working on mac os x if that matters.
            – janet
            Jul 11 '13 at 5:20










          • unfortunately, -t creates the same type of file that cat does, no break between text files read in.
            – janet
            Jul 11 '13 at 6:06










          • thank you Radu. that just about gets me what i want! sorry, i realize now that i am posting to the wrong place, as i see the notification about being off-topic. i thank you for you help!
            – janet
            Jul 11 '13 at 16:57



















          8














          To have empty lines betwen files:



          cat file1 newline file2 newline file3 > newfile


          Where 'newline' is file with empty line.






          share|improve this answer





















          • Can you clarify how to make the file newline? Some text edtiors will automatically append an end-of-line character to the last line, and others will not, so some people may experience problems making this file properly. To put this another way: does a zero-length file have zero lines, or one line?
            – Eliah Kagan
            Jul 11 '13 at 21:49










          • vim newline in vim :wq Thats it.
            – Darius Žitkevičius
            Jul 12 '13 at 5:20












          • As long as I see, "cat" puts new line automatically between each file.
            – myuce
            Nov 28 '16 at 11:18



















          0














          You can use cat to dump the text of files into one file with:



          cat file1 file2 file3 > newfile





          share|improve this answer

















          • 2




            Unfortunately cat doesn't fulfill any of the other requirements.
            – Ignacio Vazquez-Abrams
            Jul 11 '13 at 4:57






          • 1




            yes, thank you. but cat just lists the contents of each file without the original text file name and it also lists the contents of each file one after another with no break in between. i need at least 1 blank line between the contents of each text file in the new one big file.
            – janet
            Jul 11 '13 at 5:23



















          0














          for file in *.txt; do (cat "${file}"; echo) >> concatenated.txt; done


          The above will append the contents of eacb txt file into concatenated.txt adding a new line between them.






          share|improve this answer





















            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "89"
            };
            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: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            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%2faskubuntu.com%2fquestions%2f318777%2fcombine-multiple-text-files-into-one-file%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            4 Answers
            4






            active

            oldest

            votes








            4 Answers
            4






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            8














            You can use the AWK utility:



            awk 'FNR==1{print ""}{print}' *files > newfile


            Source: https://stackoverflow.com/questions/1653063/how-do-i-include-a-blank-line-between-files-im-concatenating-with-cat






            share|improve this answer























            • thank you for you suggestion. however, -T isn't being recognized. i'm working on mac os x if that matters.
              – janet
              Jul 11 '13 at 5:20










            • unfortunately, -t creates the same type of file that cat does, no break between text files read in.
              – janet
              Jul 11 '13 at 6:06










            • thank you Radu. that just about gets me what i want! sorry, i realize now that i am posting to the wrong place, as i see the notification about being off-topic. i thank you for you help!
              – janet
              Jul 11 '13 at 16:57
















            8














            You can use the AWK utility:



            awk 'FNR==1{print ""}{print}' *files > newfile


            Source: https://stackoverflow.com/questions/1653063/how-do-i-include-a-blank-line-between-files-im-concatenating-with-cat






            share|improve this answer























            • thank you for you suggestion. however, -T isn't being recognized. i'm working on mac os x if that matters.
              – janet
              Jul 11 '13 at 5:20










            • unfortunately, -t creates the same type of file that cat does, no break between text files read in.
              – janet
              Jul 11 '13 at 6:06










            • thank you Radu. that just about gets me what i want! sorry, i realize now that i am posting to the wrong place, as i see the notification about being off-topic. i thank you for you help!
              – janet
              Jul 11 '13 at 16:57














            8












            8








            8






            You can use the AWK utility:



            awk 'FNR==1{print ""}{print}' *files > newfile


            Source: https://stackoverflow.com/questions/1653063/how-do-i-include-a-blank-line-between-files-im-concatenating-with-cat






            share|improve this answer














            You can use the AWK utility:



            awk 'FNR==1{print ""}{print}' *files > newfile


            Source: https://stackoverflow.com/questions/1653063/how-do-i-include-a-blank-line-between-files-im-concatenating-with-cat







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited May 23 '17 at 12:39









            Community

            1




            1










            answered Jul 11 '13 at 5:03









            Radu RădeanuRadu Rădeanu

            116k34247323




            116k34247323












            • thank you for you suggestion. however, -T isn't being recognized. i'm working on mac os x if that matters.
              – janet
              Jul 11 '13 at 5:20










            • unfortunately, -t creates the same type of file that cat does, no break between text files read in.
              – janet
              Jul 11 '13 at 6:06










            • thank you Radu. that just about gets me what i want! sorry, i realize now that i am posting to the wrong place, as i see the notification about being off-topic. i thank you for you help!
              – janet
              Jul 11 '13 at 16:57


















            • thank you for you suggestion. however, -T isn't being recognized. i'm working on mac os x if that matters.
              – janet
              Jul 11 '13 at 5:20










            • unfortunately, -t creates the same type of file that cat does, no break between text files read in.
              – janet
              Jul 11 '13 at 6:06










            • thank you Radu. that just about gets me what i want! sorry, i realize now that i am posting to the wrong place, as i see the notification about being off-topic. i thank you for you help!
              – janet
              Jul 11 '13 at 16:57
















            thank you for you suggestion. however, -T isn't being recognized. i'm working on mac os x if that matters.
            – janet
            Jul 11 '13 at 5:20




            thank you for you suggestion. however, -T isn't being recognized. i'm working on mac os x if that matters.
            – janet
            Jul 11 '13 at 5:20












            unfortunately, -t creates the same type of file that cat does, no break between text files read in.
            – janet
            Jul 11 '13 at 6:06




            unfortunately, -t creates the same type of file that cat does, no break between text files read in.
            – janet
            Jul 11 '13 at 6:06












            thank you Radu. that just about gets me what i want! sorry, i realize now that i am posting to the wrong place, as i see the notification about being off-topic. i thank you for you help!
            – janet
            Jul 11 '13 at 16:57




            thank you Radu. that just about gets me what i want! sorry, i realize now that i am posting to the wrong place, as i see the notification about being off-topic. i thank you for you help!
            – janet
            Jul 11 '13 at 16:57













            8














            To have empty lines betwen files:



            cat file1 newline file2 newline file3 > newfile


            Where 'newline' is file with empty line.






            share|improve this answer





















            • Can you clarify how to make the file newline? Some text edtiors will automatically append an end-of-line character to the last line, and others will not, so some people may experience problems making this file properly. To put this another way: does a zero-length file have zero lines, or one line?
              – Eliah Kagan
              Jul 11 '13 at 21:49










            • vim newline in vim :wq Thats it.
              – Darius Žitkevičius
              Jul 12 '13 at 5:20












            • As long as I see, "cat" puts new line automatically between each file.
              – myuce
              Nov 28 '16 at 11:18
















            8














            To have empty lines betwen files:



            cat file1 newline file2 newline file3 > newfile


            Where 'newline' is file with empty line.






            share|improve this answer





















            • Can you clarify how to make the file newline? Some text edtiors will automatically append an end-of-line character to the last line, and others will not, so some people may experience problems making this file properly. To put this another way: does a zero-length file have zero lines, or one line?
              – Eliah Kagan
              Jul 11 '13 at 21:49










            • vim newline in vim :wq Thats it.
              – Darius Žitkevičius
              Jul 12 '13 at 5:20












            • As long as I see, "cat" puts new line automatically between each file.
              – myuce
              Nov 28 '16 at 11:18














            8












            8








            8






            To have empty lines betwen files:



            cat file1 newline file2 newline file3 > newfile


            Where 'newline' is file with empty line.






            share|improve this answer












            To have empty lines betwen files:



            cat file1 newline file2 newline file3 > newfile


            Where 'newline' is file with empty line.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jul 11 '13 at 6:55









            Darius ŽitkevičiusDarius Žitkevičius

            892




            892












            • Can you clarify how to make the file newline? Some text edtiors will automatically append an end-of-line character to the last line, and others will not, so some people may experience problems making this file properly. To put this another way: does a zero-length file have zero lines, or one line?
              – Eliah Kagan
              Jul 11 '13 at 21:49










            • vim newline in vim :wq Thats it.
              – Darius Žitkevičius
              Jul 12 '13 at 5:20












            • As long as I see, "cat" puts new line automatically between each file.
              – myuce
              Nov 28 '16 at 11:18


















            • Can you clarify how to make the file newline? Some text edtiors will automatically append an end-of-line character to the last line, and others will not, so some people may experience problems making this file properly. To put this another way: does a zero-length file have zero lines, or one line?
              – Eliah Kagan
              Jul 11 '13 at 21:49










            • vim newline in vim :wq Thats it.
              – Darius Žitkevičius
              Jul 12 '13 at 5:20












            • As long as I see, "cat" puts new line automatically between each file.
              – myuce
              Nov 28 '16 at 11:18
















            Can you clarify how to make the file newline? Some text edtiors will automatically append an end-of-line character to the last line, and others will not, so some people may experience problems making this file properly. To put this another way: does a zero-length file have zero lines, or one line?
            – Eliah Kagan
            Jul 11 '13 at 21:49




            Can you clarify how to make the file newline? Some text edtiors will automatically append an end-of-line character to the last line, and others will not, so some people may experience problems making this file properly. To put this another way: does a zero-length file have zero lines, or one line?
            – Eliah Kagan
            Jul 11 '13 at 21:49












            vim newline in vim :wq Thats it.
            – Darius Žitkevičius
            Jul 12 '13 at 5:20






            vim newline in vim :wq Thats it.
            – Darius Žitkevičius
            Jul 12 '13 at 5:20














            As long as I see, "cat" puts new line automatically between each file.
            – myuce
            Nov 28 '16 at 11:18




            As long as I see, "cat" puts new line automatically between each file.
            – myuce
            Nov 28 '16 at 11:18











            0














            You can use cat to dump the text of files into one file with:



            cat file1 file2 file3 > newfile





            share|improve this answer

















            • 2




              Unfortunately cat doesn't fulfill any of the other requirements.
              – Ignacio Vazquez-Abrams
              Jul 11 '13 at 4:57






            • 1




              yes, thank you. but cat just lists the contents of each file without the original text file name and it also lists the contents of each file one after another with no break in between. i need at least 1 blank line between the contents of each text file in the new one big file.
              – janet
              Jul 11 '13 at 5:23
















            0














            You can use cat to dump the text of files into one file with:



            cat file1 file2 file3 > newfile





            share|improve this answer

















            • 2




              Unfortunately cat doesn't fulfill any of the other requirements.
              – Ignacio Vazquez-Abrams
              Jul 11 '13 at 4:57






            • 1




              yes, thank you. but cat just lists the contents of each file without the original text file name and it also lists the contents of each file one after another with no break in between. i need at least 1 blank line between the contents of each text file in the new one big file.
              – janet
              Jul 11 '13 at 5:23














            0












            0








            0






            You can use cat to dump the text of files into one file with:



            cat file1 file2 file3 > newfile





            share|improve this answer












            You can use cat to dump the text of files into one file with:



            cat file1 file2 file3 > newfile






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jul 11 '13 at 4:51









            Atari911Atari911

            52436




            52436








            • 2




              Unfortunately cat doesn't fulfill any of the other requirements.
              – Ignacio Vazquez-Abrams
              Jul 11 '13 at 4:57






            • 1




              yes, thank you. but cat just lists the contents of each file without the original text file name and it also lists the contents of each file one after another with no break in between. i need at least 1 blank line between the contents of each text file in the new one big file.
              – janet
              Jul 11 '13 at 5:23














            • 2




              Unfortunately cat doesn't fulfill any of the other requirements.
              – Ignacio Vazquez-Abrams
              Jul 11 '13 at 4:57






            • 1




              yes, thank you. but cat just lists the contents of each file without the original text file name and it also lists the contents of each file one after another with no break in between. i need at least 1 blank line between the contents of each text file in the new one big file.
              – janet
              Jul 11 '13 at 5:23








            2




            2




            Unfortunately cat doesn't fulfill any of the other requirements.
            – Ignacio Vazquez-Abrams
            Jul 11 '13 at 4:57




            Unfortunately cat doesn't fulfill any of the other requirements.
            – Ignacio Vazquez-Abrams
            Jul 11 '13 at 4:57




            1




            1




            yes, thank you. but cat just lists the contents of each file without the original text file name and it also lists the contents of each file one after another with no break in between. i need at least 1 blank line between the contents of each text file in the new one big file.
            – janet
            Jul 11 '13 at 5:23




            yes, thank you. but cat just lists the contents of each file without the original text file name and it also lists the contents of each file one after another with no break in between. i need at least 1 blank line between the contents of each text file in the new one big file.
            – janet
            Jul 11 '13 at 5:23











            0














            for file in *.txt; do (cat "${file}"; echo) >> concatenated.txt; done


            The above will append the contents of eacb txt file into concatenated.txt adding a new line between them.






            share|improve this answer


























              0














              for file in *.txt; do (cat "${file}"; echo) >> concatenated.txt; done


              The above will append the contents of eacb txt file into concatenated.txt adding a new line between them.






              share|improve this answer
























                0












                0








                0






                for file in *.txt; do (cat "${file}"; echo) >> concatenated.txt; done


                The above will append the contents of eacb txt file into concatenated.txt adding a new line between them.






                share|improve this answer












                for file in *.txt; do (cat "${file}"; echo) >> concatenated.txt; done


                The above will append the contents of eacb txt file into concatenated.txt adding a new line between them.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 7 at 0:51









                Francisco LuzFrancisco Luz

                1011




                1011






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Ask Ubuntu!


                    • 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%2faskubuntu.com%2fquestions%2f318777%2fcombine-multiple-text-files-into-one-file%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

                    How to make a Squid Proxy server?

                    Is this a new Fibonacci Identity?

                    Touch on Surface Book