#!/bin/csh

#############################################################################
#    Copyright (C) 1993
#    Andreas Koppenhoefer (koppenh@dia.informatik.uni-stuttgart.de)
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#############################################################################
# @(#)$Id: shift.logfiles,v 1.3 1993/06/29 16:38:15 koppenh Exp $
# $Log: shift.logfiles,v $
#    Revision 1.3  1993/06/29  16:38:15  koppenh
#    Ausgabe der letzten 10 Zeilen der Nutzungsuebersicht;
#
#    Revision 1.2.0.1  1993/06/24  13:54:04  koppenh
#    Erzeugen einer Nutzungsuebersicht (Trefferquote);
#
#    Revision 1.2  1993/06/15  15:38:57  koppenh
#    Neue Release Nummer;
#
#    Revision 1.1.0.1  1993/06/08  19:42:02  koppenh
#    RCSid string korrigiert
#
#############################################################################

chdir ~plz/log

set name = "Log"
set list  =  (9 8 7 6 5 4 3 2 1 0) chmod
if (! -r $name) then
	echo Ooops, cannot read: $name
	exit 2
endif
if (-z $name) then
	echo shifting useless, empty file: $name
	exit 1
endif

set date = `date +%y.%m.%d/%T`
awk -F= ' 	\
	$2~/^ *[0-9]/	{ok++;next} 	\
	NF>1		{bad++;next} 	\
			{help++} 	\
	END		{printf "'$date' - Trefferquote %4d : %d  \t%4d Zeilen Hilfetext\n", ok, bad, help}' \
    $name >>$name.sum

while ($#list > 1)
	if ($#list > 1) then
	    if (-r $name.$list[2]) then
		/bin/mv -f $name.$list[2] $name.$list[1]
		set chmod = ($chmod $name.$list[1])
	    endif
	endif
	shift list
end
/bin/mv $name $name.$list
umask 375
touch $name
chmod 400 $chmod $name.$list

tail $name.sum
