Inserting Blank Line into File (sed/awk/?)

Jan Carlsson janne at enea.se
Sun Mar 17 09:31:21 AEST 1991


In article <1991Mar15.190607.5061 at convex.com> tchrist at convex.COM (Tom Christiansen) writes:
 >From the keyboard of tkevans at oss670.UUCP (Tim Evans):
 >:I would like to be able to insert blank lines at regular intervals
 >:in a structured file.  Specifically, I want to place a blank line after
 >:every third line in my input file.  Every third line in the input file
 >:begins with a specific character string.
 >
 >I hate doing multi-line things in sed: it's such a pain.
 >
 >If you cna really do this just by putting an extra newline
 >after each third line rather than keying off /^Name:/, just
 >use one of these:
 >
 >    awk '{ print; if (!(NR % 3)) print "\n" }'
				   ^^^^^

Make that "printf" instead since "print" always appends a newline
(ORS actually).
-- 
Jan Carlsson, Enea Data AB, Box 232, Nytorpsvaegen 5, S-183 23 Taeby, Sweden
Phone: +46 8 792 25 00  !  e-mail: janne at enea.se
Fax:   +46 8 768 43 88  !



More information about the Comp.unix.questions mailing list