#!/usr/bin/ksh

#ident	"@(#)mk:i386at/build/tools/hsplit	1.2"
#	Copyright (c) 1990, 1991, 1992, 1993, 1994 Novell, Inc. All Rights Reserved.
#	Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 Novell, Inc. All Rights Reserved.
#	  All Rights Reserved

#	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF Novell Inc.
#	The copyright notice above does not evidence any
#	actual or intended publication of such source code.


if [ $# -lt 2 ]
then
	echo "USAGE: $0 num tmpfile inputfile"
	echo "UASGE: cat inputfile | $0 num tmpfile"
	exit 1
fi

Count=$1
File=$2
shift 2

awk ' BEGIN {
		COUNT='"$Count"'
		count=COUNT
		numb=1
		FILE='\"$File.\"'
                File[Numfiles++] = FILE numb++ ""
		while ( --count != 0 ) {
                	File[Numfiles++] = FILE numb++ ""
		}
        }
        {
			out = (NR - 1) % COUNT

                print  > File[out]
        } ' $*
