Pattern matching with awk
    Tom Christiansen 
    tchrist at convex.COM
       
    Wed Mar  6 17:50:23 AEST 1991
    
    
  
>From the keyboard of louk at tslwat.UUCP (Lou Kates):
:The following   awk  program looks   for expressions of the  form
:word at 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 at convex.com	convex!tchrist
    
    
More information about the Comp.unix.questions
mailing list