bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sed ;N; reads input into core


From: Jan Nieuwenhuizen
Subject: sed ;N; reads input into core
Date: Thu, 17 Mar 2005 15:30:55 +0100
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux)

Hi,

How do I substitute a pattern that includes a newline?  Using the
standard sed recipe, sed reads the input into core

    $ proc-time sed -e ':a;N;$!ba;s/a\nb/a/g' < /usr/share/dict/dutch > 
/dev/null
    proc-time from LilyPond 1.3.55

    user:   0.36(36) system:   0.05(5)
    elapsed:   1.88
    MAXSIZE:  3.582M(917), MAXRSS:  3.582M(917)
    AVGSIZE:  1.590M(407), AVGRSS:  1.590M(407)

Without the label, sed behaves like a true stream editor

    $ proc-time sed -e 's/a\nb/a/g' </usr/share/dict/dutch > /dev/null
    proc-time from LilyPond 1.3.55

    user:   0.66(66) system:   0.01(1)
    elapsed:   2.92
    MAXSIZE:  0.555M(142), MAXRSS:  0.555M(142)
    AVGSIZE:  0.449M(115), AVGRSS:  0.449M(115)

but that does not work on even/odd line pairs:

    echo -e 'a\nb\nx\na\nb\nx\na\nb' | sed ';N;s/a\nb/c/g' 
    c
    x
    a
    b
    x
    c

Jan.

-- 
Jan Nieuwenhuizen <address@hidden> | GNU LilyPond - The music typesetter
http://www.xs4all.nl/~jantien       | http://www.lilypond.org




reply via email to

[Prev in Thread] Current Thread [Next in Thread]