On Wed, 2010-10-27 at 18:16 -0700, Liontaur wrote:
> On Wed, Oct 27, 2010 at 6:04 PM, Gary Kline <kl...@thought.org> 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/$/<text to insert>/" 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


_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"

Reply via email to