Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!convex!news From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.unix.questions Subject: Re: Pattern matching with awk Message-ID: <1991Mar06.075023.4472@convex.com> Date: 6 Mar 91 07:50:23 GMT References: <9103040310.AA16551@cs.wmich.edu> <1991Mar04.051048.5864@convex.com> <345@tslwat.UUCP> Sender: news@convex.com (news access account) Reply-To: tchrist@convex.COM (Tom Christiansen) Organization: CONVEX Software Development, Richardson, TX Lines: 30 Nntp-Posting-Host: pixel.convex.com From the keyboard of louk@tslwat.UUCP (Lou Kates): :The following awk program looks for expressions of the form :word@word where word contains only letters, numbers and dots and :the field separator is anything except letters, numbers, dots and :@. You can change the regular expressions in order to vary the :effect: : :BEGIN { FS = "[^.a-zA-Z0-9@]+"; : word = "[.a-zA-Z0-9]+"; : addr = "^" word "@" word "$" : } :{ for(i=1; i<=NF; i++) if ($i ~ addr) print $i } $ awk -f foo.awk < file awk: syntax error near line 5 awk: illegal statement near line 5 You meant a nawk program, not an awk program. You definitely need to have more characters in there -- consider folks with dashes in their hostnames. That's why my regexp was more complicated. --tom -- I get so tired of utilities with arbitrary, undocumented, compiled-in limits. Don't you? Tom Christiansen tchrist@convex.com convex!tchrist