Awk question
Daniel A. Graifer
dag at fciva.FRANKCAP.COM
Tue Jan 22 02:39:53 AEST 1991
In article <1991Jan20.232154.29651 at convex.com> tchrist at convex.COM (Tom Christiansen) writes:
>From the keyboard of jay at silence.princeton.nj.us (Jay Plett):
>:I've never been able to find a way to use a variable on the right-hand
>:side of a ~ expression with any of the incarnations of awk. Have I
>:missed something?
>
>Hmm, now that you mention it, there's no way for awk to distinguish
>
> if (myarray[i] ~ /foo/)
>
>is the literal or the variable foo.
$ nawk 'BEGIN{
x="aw fubar anyways"
foo="bar"
if ( x ~ foo )
print "Yep"
else
print "Nope"
}'
Yep
$ nawk 'BEGIN{
x="aw fubar anyways"
foo="b.r"
if ( x ~ foo )
print "Yep"
else
print "Nope"
}'
Yep
'nuff said
Dan
--
Daniel A. Graifer Coastal Capital Funding Corp.
Sr. Vice President, Financial Systems 7900 Westpark Dr. Suite A-130
(703)821-3244 McLean, VA 22102
uunet!fciva!dag fciva.FRANKCAP.COM!dag at uunet.uu.net
More information about the Comp.unix.shell
mailing list