Awk oddity

Kenneth Almquist ka at cs.washington.edu
Mon Oct 2 15:15:18 AEST 1989


> 2.	Write and test an awk script to print all input lines that contain
>	the character '='.

If you write

	awk '/=/'

awk will think that the sequence "/=" is an operator rather than the
start of a regular expression.  You can avoid this by writing

	awk '/\=/'

Or you can patch awk to handle this case.  (Look at the grammar rule
that matches a regular expression.  This handles a "/" operator.  Add
an alternative to handle the "/=" operator, which should be similar
except that it should do a "yyunput('=');" to cause the equals sign
treated as part of the regular expression.)
					Kenneth Almquist



More information about the Comp.unix.wizards mailing list