X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: Rugxulo Newsgroups: comp.os.msdos.djgpp Subject: Re: GNU sed question Date: Fri, 23 Apr 2010 13:08:44 -0700 (PDT) Organization: http://groups.google.com Lines: 28 Message-ID: <4c64a5b1-bf8a-49e1-843e-9a0594856e82@c36g2000yqm.googlegroups.com> References: NNTP-Posting-Host: 65.13.115.246 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1272053324 15899 127.0.0.1 (23 Apr 2010 20:08:44 GMT) X-Complaints-To: groups-abuse AT google DOT com NNTP-Posting-Date: Fri, 23 Apr 2010 20:08:44 +0000 (UTC) Complaints-To: groups-abuse AT google DOT com Injection-Info: c36g2000yqm.googlegroups.com; posting-host=65.13.115.246; posting-account=p5rsXQoAAAB8KPnVlgg9E_vlm2dvVhfO User-Agent: G2/1.0 X-HTTP-UserAgent: Opera/9.80 (Windows NT 5.1; U; en) Presto/2.5.22 Version/10.51,gzip(gfe) Bytes: 2148 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hi, On Apr 23, 12:05=A0pm, Mike wrote: > > Why does sed change all the first occurences of AA on each line to ZZ? > I expect sed to change only the first line: > > The sed version is 4.2.1 from delorie.com. The computer is running XP. Thanks to Eli for helping somebody yet again. ;-) For the record, if you want to only change the first line, you have to tell sed that (e.g. sed -e "1s/AA/ZZ/"), as it by default always runs over each line (whereas ed/ex/vi don't assume 1,$ address range by default). More generic sed help can be found here: http://www.pement.org/sed/index.htm http://sed.sourceforge.net/ P.S. I love GNU sed, but in my experience it's pretty darn slow on big files. Either run from a RAM drive or use GNU ed (which should load the whole file into RAM instead of parsing one line at a time) if you need better speed. Honestly, I often use csed (based upon hhsed, itself based upon Eric Raymond's version) for simpler tasks: http://lvogel.free.fr/sed.htm