Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!rochester!udel!burdvax!sirius!lang From: lang@sirius.PRC.Unisys.COM (Francois-Michel Lang) Newsgroups: comp.unix.questions Subject: variables in awk Keywords: awk Message-ID: <10029@burdvax.PRC.Unisys.COM> Date: 26 Apr 89 15:29:39 GMT Sender: news@PRC.Unisys.COM Lines: 24 An AWK question for the resident wizards: Is there any way to do pattern-matching on an AWK variable? E.g., if I want to do something every time I find a line containing the string "foo", I can say /foo/ { ... ... } Similarly, if I want to do something every time I find a line whose third word contains the string "foo", I can do $3 ~ /foo/ { ... ... } 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. ---------------------------------------------------------------------------- Francois-Michel Lang Paoli Research Center, Unisys Corporation lang@prc.unisys.com (215) 648-7256 Dept of Comp & Info Science, U of PA lang@cis.upenn.edu (215) 898-9511