Path: utzoo!utgpu!news-server.csri.toronto.edu!torsqnt!hybrid!scifi!bywater!uunet!convex!news From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.unix.questions Subject: Re: Inserting Blank Line into File (sed/awk/?) Message-ID: <1991Mar15.190607.5061@convex.com> Date: 15 Mar 91 19:06:07 GMT References: <807@oss670.UUCP> Sender: news@convex.com (news access account) Reply-To: tchrist@convex.COM (Tom Christiansen) Organization: CONVEX Software Development, Richardson, TX Lines: 19 Nntp-Posting-Host: pixel.convex.com From the keyboard of tkevans@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" }' perl -pe 's/$/\n/ unless $. % 3' perl -pe '$. % 3 || s/$/\n/' --tom