Path: utzoo!mnetor!ontmoh!peter From: peter@ontmoh.UUCP (Peter Renzland) Newsgroups: comp.unix.misc Subject: Re: awk format pgm Message-ID: <671791070.13918@ontmoh.UUCP> Date: 16 Apr 91 08:37:50 GMT References: <1991Apr12.235331.5798@ecst.csuchico.edu> Distribution: na Organization: Ontario Ministry of Health -- GOMIG BBS, Toronto, Canada Lines: 32 dbar@ecst.csuchico.edu (David Barrett) writes: >Who is good with awk? I have taken an awk script from page 120 of The Awk >Programming Language, by Aho, Kernighan and Weinberger, and tried to get [ he gets a syntax error ... ] As others have pointed out, nawk may be the name of the new awk, if it's there. If not, sometimes it's simple (though not elegant) to convert a program with functions into one without, by just replacing the call with the function code. So, in case there is no nawk, and perl is not within reach, this slightly more ugly rendition of the little program should do: /./ { for (i = 1; i <= NF; i++) { if (length(line) + length($i) > 60) if (length(line) > 0) { print substr(line, 2); line = "" } line = line " " $i } } /^$/ { if (length(line) > 0) { print substr(line, 2); line = "" }; print "" } END { if (length(line) > 0) { print substr(line, 2); line = "" } } BTW, interesting, though not very "pedantic" :-) use of the "References: " line. If I were a news tranporter (or, especially a threaded reader), I might not like that one: References: Awk Programming Language, p.120 <1991Apr12.235331.5798@ecst.csuchico.edu> -- Peter Renzland @ Ontario Ministry of Health 416/964-9141 peter@ontmoh.UUCP