#!/bin/csh -f
#
# $Header: /cujo/users/src/local/common/bin/addhost/admintools/RCS/columate,v 1.1 90/08/23 20:48:41 hardt Exp $
#
# columate
#
##
if ($#argv != 2) then
	echo "Usage: columate #columns #width"
	exit 1
endif

set columns = $argv[1]
set width   = $argv[2]
##
cat << EOF > /tmp/columate.awk
BEGIN { perline = $columns; pos = 0 }
{ 
	if (pos == 0) {
		printf("%-${width}s ",\$1);
		pos++;
	}
	else
	{
		printf("%-${width}s ",\$1);
		pos++;
	}	

	if (pos >= perline) {
		printf("\n");
		pos = 0;
	}
}
END {printf("\n");}
EOF

awk -f /tmp/columate.awk 
rm /tmp/columate.awk
