Redirecting output in AWKREAD/NEW/FOLLOWUP

cszohagan at qit.edu.au cszohagan at qit.edu.au
Sat Nov 5 05:50:43 AEST 1988


In article <1988Oct5.233609.15321 at utzoo.uucp>, henry at utzoo.uucp (Henry Spencer) writes:
> 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...
>  
> Well, it won't help you right now, but the long-term fix is to complain
> to your software supplier and ask them to get rid of the silly limit.
> It's not that hard.

The limits are based on the number of file descriptors that can be open
at one time (usually small).  One way that I often get around this is
by writting something like this which splits up the input on the field $1 .

sort +0 |
awk '
{
	if (last != $1) {
		if (NR > 0) print "!XYZZY";
		print "cat > " $1 "<<!XYZZY";
		last = $1;
	}
	print;
}
END { if (NR > 0) print "!XYZZY"; }' | /bin/sh

	Tony O'Hagan			tonyo at qitfit.qitcs.oz



More information about the Comp.unix.wizards mailing list