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

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

Re: don't work '\n' in Gnu SED for windows


From: Paolo Bonzini
Subject: Re: don't work '\n' in Gnu SED for windows
Date: Fri, 22 Aug 2008 08:52:14 +0200
User-agent: Thunderbird 2.0.0.16 (Macintosh/20080707)

Ralf Wildenhues wrote:
Hi Paolo,

* Paolo Bonzini wrote on Wed, Aug 20, 2008 at 09:58:39AM CEST:
address@hidden wrote:
I'm trying to change some string in a text file with GNU SED(FOR
WINDOWS)
but it seems that '\n' is not work!!

This means that newlines do *not* get into the pattern space. You cannot expect to use \n to match multiple lines of input. There are some tricks to do this however -- for more info look on http://sed.sf.net/grabbag for tutorials and example scripts.

You can make it work though by wrapping your script this way:

1) at the beginning put a "$!N" command

2) at the end put a "P;D" command (that's actually a P and a D)

3) execute the script with "sed -n".

This works only if you want to examine two lines at a time and if your substitution commands do not change the number of new-lines (i.e. they change 2 lines to 2 lines).

Paolo




reply via email to

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