Stupid awk question

H.Bernau ber at astbe.UUCP
Thu Oct 12 16:52:44 AEST 1989


In article <DMAUSTIN.89Oct10145918 at vivid.sun.com> dmaustin at vivid.sun.com (Darren Austin) writes:
>       I am trying to split up a large output file into several
>smaller files.  The smaller files are named after the value in
>the second field.  I tried using the following simple awk script,
>[...deleted...]
>but it fails with
>awk: too many output files 10
>Any help would be appreciated,
>--Darren

Hi.
I've had the same problem some days ago :-(
My solution was to make the awk script produce /bin/sh commands:

BEGIN { first = 1 }
(current == $2) { print }
(current != $2) { if( !first) { print "_THIS_IS_EOF_"; first = 0 }
                  current = $2;
                  printf "cat << _THIS_IS_EOF_ > %s.summary\n", $2
                }
END { print "_THIS_IS_EOF_" }

Hope that'll help.
-------------------------------------------------------------------------------
|   Rolf Bernau               |
|   GEI Software Technik mbH  |  Berlin:             astbe!ber
|   Hohenzollerndamm 150      |  USA:                ...!pyramid!tub!astbe!ber
|   1000 Berlin 33            |
|   West-Germany              |
-------------------------------------------------------------------------------



More information about the Comp.unix.questions mailing list