Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!aplcen!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.unix.questions Subject: Re: AWK Language Question Message-ID: <13540@smoke.BRL.MIL> Date: 12 Aug 90 19:21:20 GMT References: <972@richsun.cpg.trs.reuter.com> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 18 In article <972@richsun.cpg.trs.reuter.com> boi@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.