Article View: alt.comp.lang.shell.unix.bourne-bash
Article #1how to replace multiple lines in a file?
From: Jeff Weeks
Date: Tue, 10 Jun 2003 04:03
Date: Tue, 10 Jun 2003 04:03
31 lines
2750 bytes
2750 bytes
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
Technical Details
Message-ID:
<9McFa.1192$PD3.13019@nnrp1.uunet.ca>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!38.144.126.76.MISMATCH!feed2.newsreader.com!newsreader.com!newsfeed.media.kyoto-u.ac.jp!cyclone.bc.net!news.uunet.ca!nnrp1.uunet.ca.POSTED!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: faa64,bc0476873b7ef6e,start X-Google-Attributes: gidfaa64,public X-Google-Thread: 114230,bc0476873b7ef6e,start X-Google-Attributes: gid114230,public X-Google-Thread: f8c9b,bc0476873b7ef6e,start X-Google-Attributes: gidf8c9b,public X-Google-Thread: fc89c,bc0476873b7ef6e,start X-Google-Attributes: gidfc89c,public X-Google-Thread: 10183f,bc0476873b7ef6e,start X-Google-Attributes: gid10183f,public X-Google-Thread: 1012a6,bc0476873b7ef6e,start X-Google-Attributes: gid1012a6,public X-Google-Thread: fee36,bc0476873b7ef6e,start X-Google-Attributes: gidfee36,public X-Google-Thread: 10f717,bc0476873b7ef6e,start X-Google-Attributes: gid10f717,public X-Google-ArrivalTime: 2003-06-09 21:03:31 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!38.144.126.76.MISMATCH!feed2.newsreader.com!newsreader.com!newsfeed.media.kyoto-u.ac.jp!cyclone.bc.net!news.uunet.ca!nnrp1.uunet.ca.POSTED!not-for-mail From: "Jeff Weeks" <jweeks@mailandnews.com> 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: how to replace multiple lines in a file? Lines: 33 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Message-ID: <9McFa.1192$PD3.13019@nnrp1.uunet.ca> Date: Tue, 10 Jun 2003 00:03:06 -0400 NNTP-Posting-Host: 209.239.9.140 X-Trace: nnrp1.uunet.ca 1055217797 209.239.9.140 (Tue, 10 Jun 2003 00:03:17 EDT) NNTP-Posting-Date: Tue, 10 Jun 2003 00:03:17 EDT Organization: WorldCom Canada Ltd. News Reader Service