Awk with reg. exp. question
Bob Palowoda
palowoda at fiver.UUCP
Mon Mar 26 19:18:42 AEST 1990
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 at 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
More information about the Comp.unix.wizards
mailing list