Xref: utzoo comp.unix.questions:20854 comp.unix.wizards:21182 comp.unix.i386:3752 Path: utzoo!attcan!uunet!indetech!fiver!palowoda From: palowoda@fiver.UUCP (Bob Palowoda) Newsgroups: comp.unix.questions,comp.unix.wizards,comp.unix.i386 Subject: Awk with reg. exp. question Message-ID: <1031@fiver.UUCP> Date: 26 Mar 90 09:18:42 GMT Reply-To: palowoda@fiver.UUCP (Bob Palowoda) Organization: Fiver Communications, Fremont, Ca Lines: 62 I'm have a problem understanding regular expression usage in 'awk'. Maybe someone can help me out here. I might be useing the wrong awk, I have tried nawk, xenix's awk, oawk, and gnu awk version 1.7. Essentially the below script is a mail file field parser. What I don't understand is the expressions with '\t' in them. I look in all kinds of references. Included is a scirpt of the error, and what I thing the line is to be parsed. (For the FIELD) var. --------------------------------------- This would be the line to parse, it is converted to upper case by ucasep. From: palowoda@fiver.UUCP (Bob Palowoda) -------------------------------------------------------------- # This assumes that the field-names are all upper case for f in $* do FIELD=$FIELD"|"`echo $f | ucasep` done ${awk} " /^($FIELD)[ \t]*:/"' { if (current != "") print current; current = $0; next; } /^[^ \t:]+[ \t]*:/ { <-------- Here is where I think if (current != "") print current; the problem is current = ""; } /^$/ { if (current != "") print current; current = ""; exit; } /^[ \t]/ { if (current != "") current = current " " $0; } END { if (current != "") print current; } -------------------------------------- And now for the script of the error. awk: illegal primary in regular expression ^(|REPLY-TO|FROM|SENDER)[ \t]*: at REPLY-TO|FROM|SENDER)[ \t]*: source line number 2 context is /^(|REPLY-TO|FROM|SENDER)[ >>> \t]*:/ <<< { ^ | Is this the error? ----------------------------------------------------------------- ---Bob