jdm@uunet.uu.net (jdm) (06/11/89)
I have been attempting to teach myself AWK on a Sun 386i running SunOS 4.0.1. After entering numerous examples of AWK code from the book "The AWK Programming Language" by Aho, Kernighan, and Weinberger, I find that none of them run! I get error messages complaining about expressions and syntax and none of the messages give me an indication of a definitive problem. I wrote an AWK program to replace a specific character in a file with another: /;/ { sub(/;/, "X", $0) } # replace all ; with X and AWK choked on the sub() function. Likewise AWK dosen't seem to recognise "getline", "gsub", "index", "substr", etc. Does SunOS come with an older version of AWK that does not implement these functions? If not, what is going wrong? jdm@hodge.cts.com [uunet zardoz]!hodge!jdm James D. Murray, Ethnounixologist Hodge Computer Research Corporation 1588 North Batavia Street Orange, California 92667 USA TEL: (714) 998-7750 Ask for James FAX: (714) 921-8038 Wait for the carrier
jdm@uunet.uu.net (James D. Murray) (06/11/89)
I have been attempting to teach myself AWK on a Sun 386i running SunOS 4.0.1. After entering numerous examples of AWK code from the book "The AWK Programming Language" by Aho, Kernighan, and Weinberger, I find that none of them run! I get error messages complaining about expressions and syntax and none of the messages give me an indication of a definitive problem. I wrote an AWK program to replace a specific character in a file with another: /;/ { sub(/;/, "X", $0) } # replace all ; with X and AWK choked on the sub() function. Likewise AWK dosen't seem to recognise "getline", "gsub", "index", "substr", etc. Does SunOS come with an older version of AWK that does not implement these functions? If not, what is going wrong? jdm@hodge.cts.com [uunet zardoz]!hodge!jdm James D. Murray, Ethnounixologist Hodge Computer Research Corporation 1588 North Batavia Street Orange, California 92667 USA TEL: (714) 998-7750 Ask for James FAX: (714) 921-8038 Wait for the carrier #!
itwaf@gatech.edu (Bill Fulton [Sys Admin]) (06/21/89)
In article <3827@kalliope.rice.edu> hodge!jdm@uunet.uu.net (jdm) writes: >I have been attempting to teach myself AWK on a Sun 386i running SunOS >4.0.1. After entering numerous examples of AWK code from the book "The >AWK Programming Language" by Aho, Kernighan, and Weinberger, I find that >none of them run! I get error messages complaining about expressions and >syntax and none of the messages give me an indication of a definitive >problem. Note that the awk in SUNOS 3.x and 4.0 is NOT 'nawk' (new awk), and the AKW book describes nawk. The man page for awk defines the subset of the features described in the book which are available with the current SUNOS awk. It's tough to use 'old awk' after you read about 'new awk'. I posted an article about this several months ago. I got some great responses, and I appologize for not summarizing them in this newsgroup. Basicly, the 'new' implementation of awk MAY show up in SUNOS 4.1. In the meantime; I was lucky enough to finagle a copy of GNU awk ('gawk'). (And if they come out with ANOTHER version, I guess it'll be called 'yawk' - 'yet another...' - aieeeee!) This is a good imp of nawk. There are some things about it I'm not crazy about, but it seems to work ok, and the 'new' features are very, very, [very,...], handy. BTW - I'm getting more and more hooked on awk for prototypes and small scale projects. You have to use it for a few small projects before you begin to appreciate it. Anyone for an awk newsgroup? ("comp.lang.inspired_by_a_bird"?) Bill ("stop me before I parse again") Fulton P.S. There's a great description, in "Life With Unix", about an awk T-Shirt. It has a bird-like creature jumping out of a flaming aeroplane, with the caption: "Bailing out near line 1" (You gotta use awk to appreciate the humor)
aks@hub.ucsb.edu (Alan Stebbens) (06/27/89)
> BTW - I'm getting more and more hooked on awk for prototypes and small > scale projects. You have to use it for a few small projects before you > begin to appreciate it. Anyone for an awk newsgroup? > ("comp.lang.inspired_by_a_bird"?) This is not strictly limited to Sun systems, but before you get too tied up with {[ng],}awk, you might consider Larry Wall's PERL (Practical Extraction and Reporting Language). It's an *excellent* system administration tool, providing all the features of awk, csh, sed, and more, in one language, and almost always doing it faster than them all. We use it to perform system administration tasks on our groups of Sun systems (> 60 Sun 3/{50,60,80,110,260}) where the only reasonable alternative would have been to write the program in C; writing it in Perl has the advantage of reduced development time, and immediate transportability to all the other architectures we administrate. We use Perl scripts to do o User account creation o System accounting & billing reports o Network monitoring & statistics data reduction o Various system administration tasks In general, we write Perl scripts before we write csh/sh scripts. We also use "shellform" in conjunction with Perl scripts to provide forms-entry stuff. Perl is free (check various anonymous FTP sites); we have Perl installed and running on a Vax running Mt. Xinu 4.3BSD, a DecStation 3100 running Ultrix, Sun 3's running OS 3.5 and 4.0.x {0<=x<=3}, and a NeXT running Mach/4.3BSD. We originally compiled Perl with the native C compilers on each architecture, be we have recently been recompiling it with "gcc -O" to increase its performance. PS: To illustrate the power & flexibility of Perl: the Perl debugger is a Perl script!
henry@sun.com (Henry McGilton -- Software Products) (06/27/89)
James Murray and Bill Fulton correctly surmised that the version of awk documented in the book `The AWK Programming Language' is somewhat different from the plain version supplied with SunOS. I just wish here to add a general reminder to everybody that there are several books on the market purporting to document various features and applications of UNIX. These books are oftimes written by people with access to as yet un-released versions of the applications running within Bell Labs. Obviously, the authors wish to make themselves look good by writing about the newest, bluest, washes whitest versions of the software. Examples that spring immediately to mind are the books on troff, pic, tbl, and friends, written by Narain Gehani. The programs described in Gehani's books are versions not yet released outside of Bell Labs. +------------------+------------------------+---------------------------+ | Henry McGilton | I have seen the future,| arpa: hmcgilton@sun.com | | Sun Microsystems | and it doesn't work. | uucp: ...!sun!angel!henry | | Mt. View, CA | | | +------------------+------------------------+---------------------------+
lfk@mbio.med.upenn.edu (Lee Kolakowski) (07/11/89)
On 27 Jun 89 16:53:56 GMT, henry@sun.com (Henry McGilton -- Software Products) said: > James Murray and Bill Fulton correctly surmised that the version of awk > documented in the book `The AWK Programming Language' is somewhat > different from the plain version supplied with SunOS. While this awk distributed with SunOS4.0 is equivalent to the version 7 awk, there is hope for those with out the bucks to buy nawk from AT&T. The awk described in the book mentioned above is available (a clone actually) from the Free Software Fondation (Gnu Project) called GAWK. The current version is fairly stable at 2.10 and all the features mentioned in the book and a few enhancements are supported. While it is true in some cases that the books describe software not generally available, awk is not one of those cases. Frank Kolakowski ===================================================================== |lfk@mbio.med.upenn.edu || Lee F. Kolakowski | |kolakowski@mscf.med.upenn. || Univ. of Penna. | |c/o jes@eniac.seas.upenn.edu || Dept of Chemistry | |kolakowski@c.chem.upenn.edu || 231 South 34th St. | |bcooperman.kolakowski@bionet-20.arpa || Phila, PA 19104 | |AT&T: 1-215-898-2927 ||--------------------------| |#include <litigate.h> || One-Liner Here! | =====================================================================
arnold@gatech.edu (Arnold D. Robbins) (07/14/89)
SunOS In article <4225@kalliope.rice.edu> henry@sun.com (Henry McGilton -- Software Products) writes: >James Murray and Bill Fulton correctly surmised that the version of awk >documented in the book `The AWK Programming Language' is somewhat >different from the plain version supplied with SunOS. > >I just wish here to add a general reminder to everybody that there are >several books on the market purporting to document various features and >applications of UNIX. These books are oftimes written by people with >access to as yet un-released versions of the applications running within >Bell Labs. Obviously, the authors wish to make themselves look good by >writing about the newest, bluest, washes whitest versions of the software. While this may be true in some cases, in the case of AWK it just doesn't apply. The book explicitly states that 'nawk' was shipped with System V Release 3.1 *and* that it can be gotten from the ATT toolchest. (The price for *source*, for a *site license* was $300 the last time I checked. Almost anyone should be able to afford that.) It is definitely Sun's, and everyone elses' (DEC, IBM, Pyramid, whoever) fault that nawk isn't widely available on their *nix systems. Pointing fingers at book authors, *in this case*, is just a smoke screen. I will also take a paragraph and plug GNU Awk, since I'm one of the developers. It is "free" in the FSF sense, and can be gotten via anonymous ftp from prep.ai.mit.edu and anonymous UUCP from ohio-state. It can also be ordered on the FSF beta tape directly from FSF, of course. It is not bug free, but given its history, is suprisingly stable and useful. We hope to have a bug fix release Real Soon Now. Given how cheaply nawk can be gotten from the toolchest, *and* the availability of gnu awk, there is no excuse (other than simply not knowing about them) to not be using the "new" version of awk. Arnold Robbins -- Emory University Computing Center | Unix is a Registered DOMAIN: arnold@unix.cc.emory.edu | Bell of AT&T Trademark UUCP: gatech!emoryu1!arnold PHONE: +1 404 727-7636 | Laboratories. BITNET: arnold@emoryu1 FAX: +1 404 727-2599 | -- Donn Seeley