How to concatenate several text files with a blank line in-between each? [duplicate]

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











up vote
0
down vote

favorite













This question already has an answer here:



  • Concatenate multiple files with two blank lines as delimiter?

    6 answers



I am writing a shell script, and in that I am using three html files. Now I am trying to concatenate all three files, and send the content as an email to my self.



Please see below what I am trying to do
three file: hello.html, hello1.html , hello2.html.



Now I am appending the output of all these three files to file Final.Html file like below and sending it, as an email.



>Final.html
cat hello.html >> Final.html
cat hello1.html >> Final.html
cat hello2.html >> Final.html
cat Final.html | sendmail -t


Now my input of all three files is shown below



$ cat hello.html
Hello world
$ cat hello1.html
india is my world
$ cat hello2.html
India is the best


After sending the mail, the output I am getting is below



Hello world
india is my world
India is the best


The output I am looking for is below with one empty line between each file. To get a clean and clear output. Can anyone please help me on this?



Hello world

india is my world

India is the best









share|improve this question









New contributor




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











marked as duplicate by don_crissti, RalfFriedl, Jeff Schaller, Goro, Thomas Oct 3 at 9:40


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • I think Brian may have been referring to the term “o/p” as an abbreviation for “output”. I agree that “output” is more quickly understood. If these are really HTML files, do you need a <br> or similar HTML code, versus a blank line?
    – Jeff Schaller
    Oct 1 at 20:47














up vote
0
down vote

favorite













This question already has an answer here:



  • Concatenate multiple files with two blank lines as delimiter?

    6 answers



I am writing a shell script, and in that I am using three html files. Now I am trying to concatenate all three files, and send the content as an email to my self.



Please see below what I am trying to do
three file: hello.html, hello1.html , hello2.html.



Now I am appending the output of all these three files to file Final.Html file like below and sending it, as an email.



>Final.html
cat hello.html >> Final.html
cat hello1.html >> Final.html
cat hello2.html >> Final.html
cat Final.html | sendmail -t


Now my input of all three files is shown below



$ cat hello.html
Hello world
$ cat hello1.html
india is my world
$ cat hello2.html
India is the best


After sending the mail, the output I am getting is below



Hello world
india is my world
India is the best


The output I am looking for is below with one empty line between each file. To get a clean and clear output. Can anyone please help me on this?



Hello world

india is my world

India is the best









share|improve this question









New contributor




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











marked as duplicate by don_crissti, RalfFriedl, Jeff Schaller, Goro, Thomas Oct 3 at 9:40


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • I think Brian may have been referring to the term “o/p” as an abbreviation for “output”. I agree that “output” is more quickly understood. If these are really HTML files, do you need a <br> or similar HTML code, versus a blank line?
    – Jeff Schaller
    Oct 1 at 20:47












up vote
0
down vote

favorite









up vote
0
down vote

favorite












This question already has an answer here:



  • Concatenate multiple files with two blank lines as delimiter?

    6 answers



I am writing a shell script, and in that I am using three html files. Now I am trying to concatenate all three files, and send the content as an email to my self.



Please see below what I am trying to do
three file: hello.html, hello1.html , hello2.html.



Now I am appending the output of all these three files to file Final.Html file like below and sending it, as an email.



>Final.html
cat hello.html >> Final.html
cat hello1.html >> Final.html
cat hello2.html >> Final.html
cat Final.html | sendmail -t


Now my input of all three files is shown below



$ cat hello.html
Hello world
$ cat hello1.html
india is my world
$ cat hello2.html
India is the best


After sending the mail, the output I am getting is below



Hello world
india is my world
India is the best


The output I am looking for is below with one empty line between each file. To get a clean and clear output. Can anyone please help me on this?



Hello world

india is my world

India is the best









share|improve this question









New contributor




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












This question already has an answer here:



  • Concatenate multiple files with two blank lines as delimiter?

    6 answers



I am writing a shell script, and in that I am using three html files. Now I am trying to concatenate all three files, and send the content as an email to my self.



Please see below what I am trying to do
three file: hello.html, hello1.html , hello2.html.



Now I am appending the output of all these three files to file Final.Html file like below and sending it, as an email.



>Final.html
cat hello.html >> Final.html
cat hello1.html >> Final.html
cat hello2.html >> Final.html
cat Final.html | sendmail -t


Now my input of all three files is shown below



$ cat hello.html
Hello world
$ cat hello1.html
india is my world
$ cat hello2.html
India is the best


After sending the mail, the output I am getting is below



Hello world
india is my world
India is the best


The output I am looking for is below with one empty line between each file. To get a clean and clear output. Can anyone please help me on this?



Hello world

india is my world

India is the best




This question already has an answer here:



  • Concatenate multiple files with two blank lines as delimiter?

    6 answers







scripting






share|improve this question









New contributor




Nikhil 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




Nikhil 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 Oct 2 at 11:48









Kusalananda

108k14210333




108k14210333






New contributor




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









asked Oct 1 at 17:02









Nikhil

111




111




New contributor




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





New contributor





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






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




marked as duplicate by don_crissti, RalfFriedl, Jeff Schaller, Goro, Thomas Oct 3 at 9:40


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by don_crissti, RalfFriedl, Jeff Schaller, Goro, Thomas Oct 3 at 9:40


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.













  • I think Brian may have been referring to the term “o/p” as an abbreviation for “output”. I agree that “output” is more quickly understood. If these are really HTML files, do you need a <br> or similar HTML code, versus a blank line?
    – Jeff Schaller
    Oct 1 at 20:47
















  • I think Brian may have been referring to the term “o/p” as an abbreviation for “output”. I agree that “output” is more quickly understood. If these are really HTML files, do you need a <br> or similar HTML code, versus a blank line?
    – Jeff Schaller
    Oct 1 at 20:47















I think Brian may have been referring to the term “o/p” as an abbreviation for “output”. I agree that “output” is more quickly understood. If these are really HTML files, do you need a <br> or similar HTML code, versus a blank line?
– Jeff Schaller
Oct 1 at 20:47




I think Brian may have been referring to the term “o/p” as an abbreviation for “output”. I agree that “output” is more quickly understood. If these are really HTML files, do you need a <br> or similar HTML code, versus a blank line?
– Jeff Schaller
Oct 1 at 20:47










4 Answers
4






active

oldest

votes

















up vote
1
down vote













This should give the required output,



awk 'NR>1 && FNR==1print "";1' ./*.html > /path/to/Final.html


(make sure the output file is not in the list of input files)






share|improve this answer










New contributor




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













  • 1




    This is a neat solution, but it would be an even better answer if it had some description of what it is actually doing.
    – Kusalananda
    Oct 2 at 11:33










  • It will merge the contents of all files ending with .html by adding a new line after the contents of each file to Final.html
    – Kamil Khan
    Oct 2 at 11:36

















up vote
0
down vote













You can do that all with one use of cat which, while it is often used to display the contents of a file on the terminal, is actually made for con- cat -enating files (i. e. attaching them together):



$ cat hello.html hello1.html hello2.html | mail -s "Subject Goes Here" myself@mailhost.example.com





share|improve this answer




















  • Thanks, but will that really work, will cat command not take only 1 filename as a file and others as an argument?, I need a space between each file merge so that the final content shall have three different line with a space between the , i will be more than happy to check your way out as well.
    – Nikhil
    Oct 1 at 17:26










  • This will do the same as original in question, it will not add the blank lines.
    – ctrl-alt-delor
    Oct 1 at 17:31










  • Thanks much for your time,will try and update
    – Nikhil
    Oct 1 at 17:37

















up vote
0
down vote













This will do it, I have added code to add the blank lines.
echo will output a newline, it can also be used to output more.



>Final.html
cat hello.html >> Final.html
echo >> Final.html
cat hello1.html >> Final.html
echo >> Final.html
cat hello2.html >> Final.html


This next one uses a bracket, to reduce the amount of code.




cat hello.html
echo
cat hello1.html
echo
cat hello2.html
> Final.html





share|improve this answer




















  • Since i am writing in Linux text while, I shall be using echo as well right before all the lines you have mentioned?
    – Nikhil
    Oct 1 at 17:39











  • Both of my examples (above), should produce exactly the same output. However the 2nd has repeated code, so is nicer. (it only has > Final.html once)
    – ctrl-alt-delor
    Oct 1 at 17:41







  • 1




    Thank you so much
    – Nikhil
    Oct 1 at 17:43

















up vote
0
down vote













Using GNU awk (which supports the ENDFILE special pattern):



awk '1; ENDFILE print "" ' hello.html hello1.html hello2.html >Final.html


The awk script passes the data unmodified data of each file in turn (the 1; may be replaced by print , which does the same thing). At the end of each file, the ENDFILE block will output an empty line.



To additionally insert the name of the file before the data of each file (this was not part of the question):



awk 'BEGINFILE print FILENAME 1
ENDFILE print "" ' hello.html hello1.html hello2.html >Final.html


The special pattern BEGINFILE works just like ENDFILE but will be triggered before reading the first line of a new file. The FILENAME variable is a standard awk variable and contains the pathname of the current input file.






share|improve this answer





























    4 Answers
    4






    active

    oldest

    votes








    4 Answers
    4






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    This should give the required output,



    awk 'NR>1 && FNR==1print "";1' ./*.html > /path/to/Final.html


    (make sure the output file is not in the list of input files)






    share|improve this answer










    New contributor




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













    • 1




      This is a neat solution, but it would be an even better answer if it had some description of what it is actually doing.
      – Kusalananda
      Oct 2 at 11:33










    • It will merge the contents of all files ending with .html by adding a new line after the contents of each file to Final.html
      – Kamil Khan
      Oct 2 at 11:36














    up vote
    1
    down vote













    This should give the required output,



    awk 'NR>1 && FNR==1print "";1' ./*.html > /path/to/Final.html


    (make sure the output file is not in the list of input files)






    share|improve this answer










    New contributor




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













    • 1




      This is a neat solution, but it would be an even better answer if it had some description of what it is actually doing.
      – Kusalananda
      Oct 2 at 11:33










    • It will merge the contents of all files ending with .html by adding a new line after the contents of each file to Final.html
      – Kamil Khan
      Oct 2 at 11:36












    up vote
    1
    down vote










    up vote
    1
    down vote









    This should give the required output,



    awk 'NR>1 && FNR==1print "";1' ./*.html > /path/to/Final.html


    (make sure the output file is not in the list of input files)






    share|improve this answer










    New contributor




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









    This should give the required output,



    awk 'NR>1 && FNR==1print "";1' ./*.html > /path/to/Final.html


    (make sure the output file is not in the list of input files)







    share|improve this answer










    New contributor




    Kamil Khan 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 answer



    share|improve this answer








    edited Oct 2 at 11:48









    Stéphane Chazelas

    287k53530867




    287k53530867






    New contributor




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









    answered Oct 2 at 11:32









    Kamil Khan

    111




    111




    New contributor




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





    New contributor





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






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







    • 1




      This is a neat solution, but it would be an even better answer if it had some description of what it is actually doing.
      – Kusalananda
      Oct 2 at 11:33










    • It will merge the contents of all files ending with .html by adding a new line after the contents of each file to Final.html
      – Kamil Khan
      Oct 2 at 11:36












    • 1




      This is a neat solution, but it would be an even better answer if it had some description of what it is actually doing.
      – Kusalananda
      Oct 2 at 11:33










    • It will merge the contents of all files ending with .html by adding a new line after the contents of each file to Final.html
      – Kamil Khan
      Oct 2 at 11:36







    1




    1




    This is a neat solution, but it would be an even better answer if it had some description of what it is actually doing.
    – Kusalananda
    Oct 2 at 11:33




    This is a neat solution, but it would be an even better answer if it had some description of what it is actually doing.
    – Kusalananda
    Oct 2 at 11:33












    It will merge the contents of all files ending with .html by adding a new line after the contents of each file to Final.html
    – Kamil Khan
    Oct 2 at 11:36




    It will merge the contents of all files ending with .html by adding a new line after the contents of each file to Final.html
    – Kamil Khan
    Oct 2 at 11:36












    up vote
    0
    down vote













    You can do that all with one use of cat which, while it is often used to display the contents of a file on the terminal, is actually made for con- cat -enating files (i. e. attaching them together):



    $ cat hello.html hello1.html hello2.html | mail -s "Subject Goes Here" myself@mailhost.example.com





    share|improve this answer




















    • Thanks, but will that really work, will cat command not take only 1 filename as a file and others as an argument?, I need a space between each file merge so that the final content shall have three different line with a space between the , i will be more than happy to check your way out as well.
      – Nikhil
      Oct 1 at 17:26










    • This will do the same as original in question, it will not add the blank lines.
      – ctrl-alt-delor
      Oct 1 at 17:31










    • Thanks much for your time,will try and update
      – Nikhil
      Oct 1 at 17:37














    up vote
    0
    down vote













    You can do that all with one use of cat which, while it is often used to display the contents of a file on the terminal, is actually made for con- cat -enating files (i. e. attaching them together):



    $ cat hello.html hello1.html hello2.html | mail -s "Subject Goes Here" myself@mailhost.example.com





    share|improve this answer




















    • Thanks, but will that really work, will cat command not take only 1 filename as a file and others as an argument?, I need a space between each file merge so that the final content shall have three different line with a space between the , i will be more than happy to check your way out as well.
      – Nikhil
      Oct 1 at 17:26










    • This will do the same as original in question, it will not add the blank lines.
      – ctrl-alt-delor
      Oct 1 at 17:31










    • Thanks much for your time,will try and update
      – Nikhil
      Oct 1 at 17:37












    up vote
    0
    down vote










    up vote
    0
    down vote









    You can do that all with one use of cat which, while it is often used to display the contents of a file on the terminal, is actually made for con- cat -enating files (i. e. attaching them together):



    $ cat hello.html hello1.html hello2.html | mail -s "Subject Goes Here" myself@mailhost.example.com





    share|improve this answer












    You can do that all with one use of cat which, while it is often used to display the contents of a file on the terminal, is actually made for con- cat -enating files (i. e. attaching them together):



    $ cat hello.html hello1.html hello2.html | mail -s "Subject Goes Here" myself@mailhost.example.com






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Oct 1 at 17:13









    DopeGhoti

    41.5k55180




    41.5k55180











    • Thanks, but will that really work, will cat command not take only 1 filename as a file and others as an argument?, I need a space between each file merge so that the final content shall have three different line with a space between the , i will be more than happy to check your way out as well.
      – Nikhil
      Oct 1 at 17:26










    • This will do the same as original in question, it will not add the blank lines.
      – ctrl-alt-delor
      Oct 1 at 17:31










    • Thanks much for your time,will try and update
      – Nikhil
      Oct 1 at 17:37
















    • Thanks, but will that really work, will cat command not take only 1 filename as a file and others as an argument?, I need a space between each file merge so that the final content shall have three different line with a space between the , i will be more than happy to check your way out as well.
      – Nikhil
      Oct 1 at 17:26










    • This will do the same as original in question, it will not add the blank lines.
      – ctrl-alt-delor
      Oct 1 at 17:31










    • Thanks much for your time,will try and update
      – Nikhil
      Oct 1 at 17:37















    Thanks, but will that really work, will cat command not take only 1 filename as a file and others as an argument?, I need a space between each file merge so that the final content shall have three different line with a space between the , i will be more than happy to check your way out as well.
    – Nikhil
    Oct 1 at 17:26




    Thanks, but will that really work, will cat command not take only 1 filename as a file and others as an argument?, I need a space between each file merge so that the final content shall have three different line with a space between the , i will be more than happy to check your way out as well.
    – Nikhil
    Oct 1 at 17:26












    This will do the same as original in question, it will not add the blank lines.
    – ctrl-alt-delor
    Oct 1 at 17:31




    This will do the same as original in question, it will not add the blank lines.
    – ctrl-alt-delor
    Oct 1 at 17:31












    Thanks much for your time,will try and update
    – Nikhil
    Oct 1 at 17:37




    Thanks much for your time,will try and update
    – Nikhil
    Oct 1 at 17:37










    up vote
    0
    down vote













    This will do it, I have added code to add the blank lines.
    echo will output a newline, it can also be used to output more.



    >Final.html
    cat hello.html >> Final.html
    echo >> Final.html
    cat hello1.html >> Final.html
    echo >> Final.html
    cat hello2.html >> Final.html


    This next one uses a bracket, to reduce the amount of code.




    cat hello.html
    echo
    cat hello1.html
    echo
    cat hello2.html
    > Final.html





    share|improve this answer




















    • Since i am writing in Linux text while, I shall be using echo as well right before all the lines you have mentioned?
      – Nikhil
      Oct 1 at 17:39











    • Both of my examples (above), should produce exactly the same output. However the 2nd has repeated code, so is nicer. (it only has > Final.html once)
      – ctrl-alt-delor
      Oct 1 at 17:41







    • 1




      Thank you so much
      – Nikhil
      Oct 1 at 17:43














    up vote
    0
    down vote













    This will do it, I have added code to add the blank lines.
    echo will output a newline, it can also be used to output more.



    >Final.html
    cat hello.html >> Final.html
    echo >> Final.html
    cat hello1.html >> Final.html
    echo >> Final.html
    cat hello2.html >> Final.html


    This next one uses a bracket, to reduce the amount of code.




    cat hello.html
    echo
    cat hello1.html
    echo
    cat hello2.html
    > Final.html





    share|improve this answer




















    • Since i am writing in Linux text while, I shall be using echo as well right before all the lines you have mentioned?
      – Nikhil
      Oct 1 at 17:39











    • Both of my examples (above), should produce exactly the same output. However the 2nd has repeated code, so is nicer. (it only has > Final.html once)
      – ctrl-alt-delor
      Oct 1 at 17:41







    • 1




      Thank you so much
      – Nikhil
      Oct 1 at 17:43












    up vote
    0
    down vote










    up vote
    0
    down vote









    This will do it, I have added code to add the blank lines.
    echo will output a newline, it can also be used to output more.



    >Final.html
    cat hello.html >> Final.html
    echo >> Final.html
    cat hello1.html >> Final.html
    echo >> Final.html
    cat hello2.html >> Final.html


    This next one uses a bracket, to reduce the amount of code.




    cat hello.html
    echo
    cat hello1.html
    echo
    cat hello2.html
    > Final.html





    share|improve this answer












    This will do it, I have added code to add the blank lines.
    echo will output a newline, it can also be used to output more.



    >Final.html
    cat hello.html >> Final.html
    echo >> Final.html
    cat hello1.html >> Final.html
    echo >> Final.html
    cat hello2.html >> Final.html


    This next one uses a bracket, to reduce the amount of code.




    cat hello.html
    echo
    cat hello1.html
    echo
    cat hello2.html
    > Final.html






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Oct 1 at 17:31









    ctrl-alt-delor

    9,23831948




    9,23831948











    • Since i am writing in Linux text while, I shall be using echo as well right before all the lines you have mentioned?
      – Nikhil
      Oct 1 at 17:39











    • Both of my examples (above), should produce exactly the same output. However the 2nd has repeated code, so is nicer. (it only has > Final.html once)
      – ctrl-alt-delor
      Oct 1 at 17:41







    • 1




      Thank you so much
      – Nikhil
      Oct 1 at 17:43
















    • Since i am writing in Linux text while, I shall be using echo as well right before all the lines you have mentioned?
      – Nikhil
      Oct 1 at 17:39











    • Both of my examples (above), should produce exactly the same output. However the 2nd has repeated code, so is nicer. (it only has > Final.html once)
      – ctrl-alt-delor
      Oct 1 at 17:41







    • 1




      Thank you so much
      – Nikhil
      Oct 1 at 17:43















    Since i am writing in Linux text while, I shall be using echo as well right before all the lines you have mentioned?
    – Nikhil
    Oct 1 at 17:39





    Since i am writing in Linux text while, I shall be using echo as well right before all the lines you have mentioned?
    – Nikhil
    Oct 1 at 17:39













    Both of my examples (above), should produce exactly the same output. However the 2nd has repeated code, so is nicer. (it only has > Final.html once)
    – ctrl-alt-delor
    Oct 1 at 17:41





    Both of my examples (above), should produce exactly the same output. However the 2nd has repeated code, so is nicer. (it only has > Final.html once)
    – ctrl-alt-delor
    Oct 1 at 17:41





    1




    1




    Thank you so much
    – Nikhil
    Oct 1 at 17:43




    Thank you so much
    – Nikhil
    Oct 1 at 17:43










    up vote
    0
    down vote













    Using GNU awk (which supports the ENDFILE special pattern):



    awk '1; ENDFILE print "" ' hello.html hello1.html hello2.html >Final.html


    The awk script passes the data unmodified data of each file in turn (the 1; may be replaced by print , which does the same thing). At the end of each file, the ENDFILE block will output an empty line.



    To additionally insert the name of the file before the data of each file (this was not part of the question):



    awk 'BEGINFILE print FILENAME 1
    ENDFILE print "" ' hello.html hello1.html hello2.html >Final.html


    The special pattern BEGINFILE works just like ENDFILE but will be triggered before reading the first line of a new file. The FILENAME variable is a standard awk variable and contains the pathname of the current input file.






    share|improve this answer


























      up vote
      0
      down vote













      Using GNU awk (which supports the ENDFILE special pattern):



      awk '1; ENDFILE print "" ' hello.html hello1.html hello2.html >Final.html


      The awk script passes the data unmodified data of each file in turn (the 1; may be replaced by print , which does the same thing). At the end of each file, the ENDFILE block will output an empty line.



      To additionally insert the name of the file before the data of each file (this was not part of the question):



      awk 'BEGINFILE print FILENAME 1
      ENDFILE print "" ' hello.html hello1.html hello2.html >Final.html


      The special pattern BEGINFILE works just like ENDFILE but will be triggered before reading the first line of a new file. The FILENAME variable is a standard awk variable and contains the pathname of the current input file.






      share|improve this answer
























        up vote
        0
        down vote










        up vote
        0
        down vote









        Using GNU awk (which supports the ENDFILE special pattern):



        awk '1; ENDFILE print "" ' hello.html hello1.html hello2.html >Final.html


        The awk script passes the data unmodified data of each file in turn (the 1; may be replaced by print , which does the same thing). At the end of each file, the ENDFILE block will output an empty line.



        To additionally insert the name of the file before the data of each file (this was not part of the question):



        awk 'BEGINFILE print FILENAME 1
        ENDFILE print "" ' hello.html hello1.html hello2.html >Final.html


        The special pattern BEGINFILE works just like ENDFILE but will be triggered before reading the first line of a new file. The FILENAME variable is a standard awk variable and contains the pathname of the current input file.






        share|improve this answer














        Using GNU awk (which supports the ENDFILE special pattern):



        awk '1; ENDFILE print "" ' hello.html hello1.html hello2.html >Final.html


        The awk script passes the data unmodified data of each file in turn (the 1; may be replaced by print , which does the same thing). At the end of each file, the ENDFILE block will output an empty line.



        To additionally insert the name of the file before the data of each file (this was not part of the question):



        awk 'BEGINFILE print FILENAME 1
        ENDFILE print "" ' hello.html hello1.html hello2.html >Final.html


        The special pattern BEGINFILE works just like ENDFILE but will be triggered before reading the first line of a new file. The FILENAME variable is a standard awk variable and contains the pathname of the current input file.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Oct 2 at 11:50

























        answered Oct 2 at 11:42









        Kusalananda

        108k14210333




        108k14210333












            Popular posts from this blog

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

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay