[comp.unix.questions] awk questions: >10 output files; RS

hamilton@aztec.osbusouth.xerox.COM (Bruce Hamilton) (04/15/89)

Since there's no comp.lang.awk, this must be the place...

I just bought Aho, Kernighan, & Weinberger and started
playing.  I may never use another language!  :-)

I did run into a couple of glitches:

-how can I get more than ten output files?  Even when I
explicitly "close"d each file after writing each record, awk
still barfed after writing 10 files.  I know I could up-level
and write an awk to generate awks to handle groups of
ten records, but then that is only good for 100 records...

-is there any way to set RS to a string, instead of just
one character?  It would allow me to write cleaner code
with fewer calls to substring to chop off beginnings and
endings of records.

Kindly cc: me by e-mail.

Thanks,

--Bruce
CSNet: Hamilton.osbuSouth@Xerox.COM
UUCP: xerox.com!hamilton.osbuSouth

domo@riddle.UUCP (Dominic Dunlop) (04/26/89)

In article <255@aztec.osbusouth.xerox.COM> hamilton.osbuSouth@Xerox.COM
(Bruce Hamilton) writes:
>
>-how can I get more than ten output files?  [in awk]

Thought this was fixed in nawk.  Or am I wrong?  Anyway, the way to get
around this `feature' of awk is to have awk create a shell script with here
documents, than feed it to a shell.  If you feel ambitious you can have awk
pipe the data itself by putting | "sh" on the end of all the printing
commands, otherwise, just do it in the shell:

	awk -f script input | sh

What awk should be spitting out is something like

	cat << E_O_F >file001
		lines of
		data for
		file001
	E_O_F
	cat << E_O_F >file002
		lines of
		data for
		file002
	E_O_F
	...
	cat << E_O_F >filennn
		lines of
		data for
		filennn
	E_O_F

(Think that's the third time I've posted this in the last few years.  I
must be getting old...)
-- 
Dominic Dunlop
The Standard Answer Ltd., using Sphinx' facilities (for which much thanks)
domo@sphinx.co.uk