awk format pgm
Peter Renzland
peter at ontmoh.UUCP
Tue Apr 16 18:37:50 AEST 1991
dbar at 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 at ecst.csuchico.edu>
--
Peter Renzland @ Ontario Ministry of Health 416/964-9141 peter at ontmoh.UUCP
More information about the Comp.unix.misc
mailing list