Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Is this a job for awk?

Received: by 10.68.223.40 with SMTP id qr8mr15376506pbc.0.1337372578190;
        Fri, 18 May 2012 13:22:58 -0700 (PDT)
Path: pr3ni2379pbb.0!nntp.google.com!news1.google.com!postnews.google.com!eh4g2000vbb.googlegroups.com!not-for-mail
From: presidentbyamendment <rick_hohen...@email.com>
Newsgroups: comp.lang.awk
Subject: Re: Is this a job for awk?
Date: Fri, 18 May 2012 13:22:57 -0700 (PDT)
Organization: http://groups.google.com
Lines: 19
Message-ID: <38995389-a4a6-4e19-b33b-b562356574f7@eh4g2000vbb.googlegroups.com>
References: <ec5887b3114b20926b71d2fe5b3f0267@msgid.frell.theremailer.net>
NNTP-Posting-Host: 64.134.103.11
Mime-Version: 1.0
X-Trace: posting.google.com 1337372578 16428 127.0.0.1 (18 May 2012 20:22:58 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 18 May 2012 20:22:58 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: eh4g2000vbb.googlegroups.com; posting-host=64.134.103.11; posting-account=OcRAMAoAAAArFDHhZFYw2-58_dk-x0_f
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20100101 Firefox/12.0,gzip(gfe)
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

On May 8, 11:06=A0am, Fritz Wuehler
<fr...@spamexpire-201205.rodent.frell.theremailer.net> wrote:
> Hello guys I stumbled upon awk today and it's pretty neat. I am thinking
> about an application and I don't know if it's better to write it in C or
> awk. Basically I want to scan source for certain commands and do a
> substitution like the cpp on steroids. Doing the regexp and matching for
> hits on the input text and doing the replacements is pretty easy so far b=
ut
> I don't know how to copy lines that don't match to the output! Every line
> will either be echoed or transformed. I don't get how to copy non matchin=
g
> lines unless I process every line as $0 and do a bunch of if else and the=
n
> fall through to just writing the whole line if it doesn't match. Like I
> would do it in C. But that seems to go against awk's pattern action
> philosophy. Would that be too inefficient or is there an elegant way to
> (gr)awk this?

Awk is OK for that, but you might want ed. Or sed.