| Author |
adding blank lines to a file
|
|
| Ricardo Pan 2007-06-19, 9:57 pm |
| 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
| |
| Vassilis 2007-06-19, 9:57 pm |
|
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
| |
| Janis Papanagnou 2007-06-19, 9:57 pm |
| 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
>
| |
|
|
|
|
|
|
|
|