adding blank lines to a file - awk

This is a discussion on adding blank lines to a file - awk ; Hello ... how do I add a blank line after some defined number of lines? Regards Example: I have a file with 100 lines, after 10 lines I would like to add a blank line. 1st line 2nd line 3rd ...

+ Reply to Thread
Results 1 to 3 of 3

adding blank lines to a file

  1. Default adding blank lines to a file

    Hello ... how do I add a blank line after some defined number of
    lines?

    Regards

    Example: I have a file with 100 lines, after 10 lines I would like to
    add a blank line.

    1st line
    2nd line
    3rd line
    4th line
    5th line
    10th line
    blank line
    11th line
    12th line
    ....
    20th line
    blank line
    21st line
    22nd line
    23rd line
    ....
    30th line
    blank line
    ....
    ....
    ....
    blank line
    91st line
    92nd line
    93rd line
    ....
    100th line


  2. Default Re: adding blank lines to a file


    Ricardo Pan :
    > Hello ... how do I add a blank line after some defined number of
    > lines?
    >
    > Regards
    >
    > Example: I have a file with 100 lines, after 10 lines I would like to
    > add a blank line.
    >
    > 1st line
    > 2nd line
    > 3rd line
    > 4th line
    > 5th line
    > 10th line
    > blank line
    > 11th line
    > 12th line
    > ...
    > 20th line
    > blank line
    > 21st line
    > 22nd line
    > 23rd line
    > ...
    > 30th line
    > blank line
    > ...
    > ...
    > ...
    > blank line
    > 91st line
    > 92nd line
    > 93rd line
    > ...
    > 100th line



    awk '{ print } NR % 10 == 0 { print "" }' input

    Vassilis


  3. Default Re: adding blank lines to a file

    Ricardo Pan wrote:
    > Hello ... how do I add a blank line after some defined number of
    > lines?
    >
    > Regards
    >
    > Example: I have a file with 100 lines, after 10 lines I would like to
    > add a blank line.


    awk 'ORS=NR%10?"\n":"\n\n"'

    Janis

    >
    > 1st line
    > 2nd line
    > 3rd line
    > 4th line
    > 5th line
    > 10th line
    > blank line
    > 11th line
    > 12th line
    > ...
    > 20th line
    > blank line
    > 21st line
    > 22nd line
    > 23rd line
    > ...
    > 30th line
    > blank line
    > ...
    > ...
    > ...
    > blank line
    > 91st line
    > 92nd line
    > 93rd line
    > ...
    > 100th line
    >


+ Reply to Thread

Similar Threads

  1. Reading a file containing blank lines
    By Application Development in forum Fortran
    Replies: 10
    Last Post: 10-10-2007, 10:06 AM
  2. [vi] How to delete blank lines
    By Application Development in forum Editors
    Replies: 5
    Last Post: 08-28-2007, 04:54 PM
  3. Preserve blank lines when add multiple lines of text to a cell
    By Application Development in forum Javascript
    Replies: 0
    Last Post: 04-22-2007, 11:47 PM
  4. Blank lines in header
    By Application Development in forum Mutt
    Replies: 2
    Last Post: 04-07-2006, 04:03 PM
  5. Replies: 1
    Last Post: 11-30-2005, 07:04 AM