Redirecting output in AWK

Leslie Mikesell les at chinet.UUCP
Wed Oct 5 13:17:49 AEST 1988


In article <816 at mergvax> rkxyv at mergvax (Rob Kedoin) writes:

>I am trying to use AWK to split one file into many formatted, smaller files.

>The problem I am having is that I cannot output to more than 10 files.  I am
>doing my output in a manner similar to:
>	MY_FILE="foo";
>	printf("abc\n") >> MY_FILE;
>	close(MY_FILE);
>Even though I am executing the close, I am still running out of files.  Does
>anyone know of a fix to this ?

This is supposed to be fixed in the SysVr3 new awk (nawk).  However I've
done something similar by generating a shar-like output and piping it
to /bin/sh.  The output can look something like this:
cat >file1 <<!EOF
..contents of file1
!EOF
cat >file2 <<!EOF
..contents of file2
!EOF
..etc.

Or, of course, you could use Larry Wall's perl which does not have
awk's limitations.

Les Mikesell



More information about the Comp.unix.questions mailing list