AWK Language Question

Doug Gwyn gwyn at smoke.BRL.MIL
Mon Aug 13 05:21:20 AEST 1990


In article <972 at richsun.cpg.trs.reuter.com> boi at richsun.cpg.trs.reuter.com (Ken Boi) writes:
>According to the book "The AWK Programming Language", there
>are built-in string functions. One of them is 'gsub'. I have 
>tried using it with the following comand line statement which
>is very close to the example in the book:
>		awk '{ gsub(/USA/, "United States"); print }' awkdata
>where 'awkdata' is any text file. I get the error messages:
>		awk: syntax error near line 1
>		awk: illegal statement near line 1
>Anybody know why?

Sure -- your version of "awk" is an old one that doesn't support that
feature.  Except for the first chapter or so of the AWK book, the examples
depend on having a more modern version of awk.  If you have a command "nawk"
try using that.  Otherwise, you can obtain the new flavor of awk from the
AT&T UNIX System ToolChest, or from UNIX System V Release 3.2 or later,
or a (supposedly) functionally equivalent utility called "gawk" from the
GNU project.



More information about the Comp.unix.questions mailing list