Message from discussion
Searching strings with awk
Path: g2news1.google.com!news1.google.com!postnews.google.com!s37g2000vbp.googlegroups.com!not-for-mail
From: Ed Morton <mortons...@gmail.com>
Newsgroups: comp.lang.awk
Subject: Re: Searching strings with awk
Date: Wed, 10 Dec 2008 12:57:52 -0800 (PST)
Organization: http://groups.google.com
Lines: 49
Message-ID: <2d652609-7f68-4a45-9080-6336f1199c4b@s37g2000vbp.googlegroups.com>
References: <86ec0667-4bb9-4837-afad-1c35fed3988b@l39g2000yqn.googlegroups.com>
<ghooue$24d$1@pentheus.materna.de> <a41c5c09-c8f8-4958-a502-fa99f905140f@m22g2000vbl.googlegroups.com>
<ghp1us$vs$1@news.xmission.com> <31ff1$49400ed9$cef88ba3$28412@TEKSAVVY.COM>
NNTP-Posting-Host: 67.176.249.87
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1228942672 13016 127.0.0.1 (10 Dec 2008 20:57:52 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Wed, 10 Dec 2008 20:57:52 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: s37g2000vbp.googlegroups.com; posting-host=67.176.249.87;
posting-account=rv7-7goAAAAyBCsUgaHaGs9haWRFGhT0
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET
CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1; .NET CLR 3.0.04506.30),gzip(gfe),gzip(gfe)
On Dec 10, 12:47=A0pm, "Chris F.A. Johnson" <cfajohn...@gmail.com>
wrote:
> On 2008-12-10, Kenny McCormack wrote:
>
> > In article <a41c5c09-c8f8-4958-a502-fa99f9051...@m22g2000vbl.googlegrou=
ps.com>,
> > Ed Morton =A0<mortons...@gmail.com> wrote:
> > ...
> >>No, that's not how you pass the value of shell variables to an awk
> >>script. Blah, blah, blah.
>
> > No, that *is* how he passes shell variables to an AWK script.
> > It also happens to be how I (usually) do it.
>
> =A0 =A0And your script would fail if $1 contains spaces. I would hope tha=
t
> =A0 =A0you actually do this:
>
> gawk ' BEGIN { RS=3D"---*" }
> =A0 =A0 =A0 =A0/'"$pattern"'/ ' "$@"
and then it'd still fail with obscure error messages for some other
values of pattern, e.g.:
$ pattern=3D"foo
bar"
$ gawk ' BEGIN { RS=3D"---*" }
/'"$pattern"'/ ' "$@" file
gawk: cmd. line:1: /foo
gawk: cmd. line:1: ^ unterminated regexp
gawk: cmd. line:3: bar/
gawk: cmd. line:3: ^ unexpected newline or end of string
$ pattern=3D"\\"
$ gawk ' BEGIN { RS=3D"---*" }
/'"$pattern"'/ ' "$@" file
gawk: cmd. line:1: /\/
gawk: cmd. line:1: ^ unterminated regexp
$ pattern=3D"12/25/2008"
$ gawk ' BEGIN { RS=3D"---*" }
/'"$pattern"'/ ' "$@" file
gawk: cmd. line:2: /12/25/2008/
gawk: cmd. line:2: ^ unexpected newline or end of
string
Regards,
Ed.