Article View: alt.comp.lang.shell.unix.bourne-bash
Article #6Re: how to replace multiple lines in a file?
From: Juergen Heck
Date: Wed, 11 Jun 2003 14:56
Date: Wed, 11 Jun 2003 14:56
41 lines
2953 bytes
2953 bytes
Jeff Weeks schrieb: > > Hello, > > I have a file, in a certain format grammer, which I wish to convert to > another grammer, and I'm having trouble converting expressions that span > multiple lines: > > For example, changing: > [html] > <pre> > > to simply: > [code] > > I can't seem to use regular expressions to find the initial multi-line item. > I'm also confused as to which utility I should be using to accomplish this. > I assumed sed would be the best tool for the task, but I'm not overly > familiar with it, so perhaps I'm wrong? > > Can regular expressions even span multiple lines? > I've tried ^\[html\]$^<pre> to match it, but I would imagine having multiple > ^'s confuse the parser. > I've also tried using \n, but I don't believe that's recognised as valid > syntax. > > Essentially, I'm just wondering if anybody has a solution to this using > basic unix utilities (bash, sed, awk, etc). I'd rather not write a C > program to do something that'd probably easier done otherwise. > > Thanks, > Jeff > jweeks at mailandnews dot com sed '/^\[html\]/,/^<pre>/c\ [code]' infile Regards Juergen
Technical Details
Message-ID:
<3EE74334.8A4EB987@t-online.de>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!newsfeed.news2me.com!newsfeed.icl.net!newsfeed.fjserv.net!news-FFM2.ecrc.net!newsfeed00.sul.t-online.de!newsmm00.sul.t-online.com!t-online.de!news.t-online.com!not-for-mailReferences:
<9McFa.1192$PD3.13019@nnrp1.uunet.ca>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 114230,bc0476873b7ef6e X-Google-Attributes: gid114230,public X-Google-Thread: f8c9b,bc0476873b7ef6e X-Google-Attributes: gidf8c9b,public X-Google-Thread: faa64,bc0476873b7ef6e X-Google-Attributes: gidfaa64,public X-Google-Thread: fc89c,bc0476873b7ef6e X-Google-Attributes: gidfc89c,public X-Google-Thread: fee36,bc0476873b7ef6e X-Google-Attributes: gidfee36,public X-Google-Thread: 1012a6,bc0476873b7ef6e X-Google-Attributes: gid1012a6,public X-Google-Thread: 10f717,bc0476873b7ef6e X-Google-Attributes: gid10f717,public X-Google-Thread: 10183f,bc0476873b7ef6e X-Google-Attributes: gid10183f,public X-Google-ArrivalTime: 2003-06-12 03:49:23 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!newsfeed.news2me.com!newsfeed.icl.net!newsfeed.fjserv.net!news-FFM2.ecrc.net!newsfeed00.sul.t-online.de!newsmm00.sul.t-online.com!t-online.de!news.t-online.com!not-for-mail From: Juergen Heck <btd.heck@t-online.de> Newsgroups: alt.comp.lang.shell.unix.bourne-bash,alt.os.linux,alt.unix.geeks,ca.unix,comp.unix,comp.unix.programmer,comp.unix.questions,comp.unix.shell Subject: Re: how to replace multiple lines in a file? Date: Wed, 11 Jun 2003 16:56:52 +0200 Organization: Beratung-Training-Dokumentation Lines: 41 Message-ID: <3EE74334.8A4EB987@t-online.de> References: <9McFa.1192$PD3.13019@nnrp1.uunet.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.t-online.com 1055343412 04 21825 ogfXVSFVSZaI2q 030611 14:56:52 X-Complaints-To: usenet-abuse@t-online.de X-ID: SSR87sZHrehSGlR22CNCOYX7B-j9aevx3AZI-1F-3lpauRFK9fkg8r X-Mailer: Mozilla 4.73 [de]C-CCK-MCD DT (Win98; U) X-Accept-Language: de