Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!enea!janne From: janne@enea.se (Jan Carlsson) Newsgroups: comp.unix.questions Subject: Re: Inserting Blank Line into File (sed/awk/?) Message-ID: <2828@enea.se> Date: 16 Mar 91 23:31:21 GMT References: <807@oss670.UUCP> <1991Mar15.190607.5061@convex.com> Organization: Enea Data AB, Sweden Lines: 22 In article <1991Mar15.190607.5061@convex.com> tchrist@convex.COM (Tom Christiansen) writes: >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" }' ^^^^^ 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@enea.se Fax: +46 8 768 43 88 !