From owner-freebsd-questions@FreeBSD.ORG Thu Oct 28 16:29:52 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E97511065672 for ; Thu, 28 Oct 2010 16:29:52 +0000 (UTC) (envelope-from kline@thought.org) Received: from thought.org (plato.thought.org [209.180.213.209]) by mx1.freebsd.org (Postfix) with ESMTP id B99338FC16 for ; Thu, 28 Oct 2010 16:29:52 +0000 (UTC) Received: by thought.org (Postfix, from userid 1001) id 96450E819F9; Thu, 28 Oct 2010 09:29:27 -0700 (PDT) Date: Thu, 28 Oct 2010 09:29:27 -0700 From: Gary Kline To: Wayne Sierke Message-ID: <20101028162927.GA11082@thought.org> References: <20101028010447.GA9734@thought.org> <1288241282.32933.82.camel@predator-ii.buffyverse> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1288241282.32933.82.camel@predator-ii.buffyverse> X-Organization: Thought Unlimited. Public service Unix since 1986. X-Of_Interest: With 24 years of service to the Unix community. User-Agent: Mutt/1.5.20 (2009-06-14) Cc: FreeBSD Mailing List , Liontaur Subject: Re: okay, time to ask the wizards. X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Oct 2010 16:29:53 -0000 On Thu, Oct 28, 2010 at 03:18:02PM +1030, Wayne Sierke wrote: > On Wed, 2010-10-27 at 18:16 -0700, Liontaur wrote: > > On Wed, Oct 27, 2010 at 6:04 PM, Gary Kline wrote: > > > > > I've got a very large file with paragraphs separated only by "\n". > > > How do I put a blank line _after_ each newline? > > > > > > > > Perhaps using sed? i'm definitely no sed expert but the substitute command > > would work, just substitute one \n with two? > > > > Mark > > Not quite. When considering sed(1), recall that: > > Normally, sed cyclically copies a line of input, not including > its terminating newline character, into a pattern space, ... > (then) copies the pattern space to the standard output, > appending a newline, and deletes the pattern space. > > So there is no "\n" in the initial pattern space to be substituted. > Characters can however be inserted at the end of the line (before the > original \n) with: "s/$//" as Chad used in his perl > solution. Unfortunately FreeBSD sed's "substitute" doesn't recognise > "\n" as "newline" in a substitution, although it's possible to insert a > literal "newline" character through various shell-dependent techniques. > > In this particular case however, sed does offer the "pièce de > résistance": > > sed G > > > The operation is left as a learning exercise for the reader. > > > Wayne > Well, I hope this mouse and paste works across konsoles. I've had this stuff in my ~/.HowTo file for a couple years. I don't remember the % sed G bit, but it would've saved a lot of electrons. %%% sed howto's: FILE SPACING: # double space a file sed G # double space a file which already has blank lines in it. Output file # should contain no more than one blank line between lines of text. sed '/^$/d;G' # triple space a file sed 'G;G' Yup. Works. So there, gents, you've got it from "wherever I got it from." thanks for the insights from ``y'all|you-all|you'n's|everybody'' gary > -- Gary Kline kline@thought.org http://www.thought.org Public Service Unix The 7.90a release of Jottings: http://jottings.thought.org/index.php http://journey.thought.org