Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rutgers!pyrnj!dasys1!jpr From: jpr@dasys1.UUCP (Jean-Pierre Radley) Newsgroups: comp.unix.questions Subject: Re: variables in awk Keywords: awk Message-ID: <9494@dasys1.UUCP> Date: 30 Apr 89 15:28:10 GMT References: <10029@burdvax.PRC.Unisys.COM> Reply-To: jpr@dasys1.UUCP (Jean-Pierre Radley) Organization: TANGENT Lines: 36 In article <10029@burdvax.PRC.Unisys.COM> lang@sirius.PRC.Unisys.COM (Francois-Michel Lang) writes: >An AWK question for the resident wizards: >Is there any way to do pattern-matching on an AWK variable? Yes, why not? >Now, the question is, what if I want to match not against >a given string (which is fixed at "compile time"), >but against an AWK variable, whose value can change >in the course of the life of the AWK script. >I can't find anything in any AWK documentation >that tells me that this is possible, and, if so, >how to do it. Any pointers would be appreciated. Awk variables are valid anywhere in an awk script. Maybe I'll just give you an example excerpted from some code of mine: awk ' ... $4!=Num { ... } { AccT+=$6; GT+=$6; ST+=$6; Num=$4 ... } ... ' At some point I set the variable Num equal to something. At some other point, I test it. Just do it. -- Jean-Pierre Radley Honi soit jpr@dasys1.UUCP New York, New York qui mal ...!hombre!jpradley!jpr CIS: 76120,1341 y pense ...!hombre!trigere!jpr