#partie1

last=`mktemp`
lastReboot=`mktemp`
tmp=`mktemp`
last > $last



nombreArgument=$#
if [ $nombreArgument -eq 1 ]
then

if [ $1 = '-crimes' ] 
then
 sed -n '/reboot/p'  $last >$lastReboot
sed -n $i'p' $lastReboot > $tmp
i=1
while [ $i -lt `wc -l<$last` ]
do 

sed -n $i'p' $lastReboot > $tmp

cut -c 40- $tmp 
i=$[i+1]

done


elif [ $1 = '-crime' ] 
then
 sed -n '/reboot/p' $last | sed -n '1p' $lastReboot 


elif [ $1 = '-victime' ] 
then
grep -n 'reboot' $last > $lastReboot
echo 'nonnul' > $tmp
i=1
ligne=0
while [ $ligne -lt `tail -n 1 $lastReboot | cut -d ':' -f 1` ]
do
i=$[i+1]
sed -n $i'p' $lastReboot >$tmp

ligne=`cut -d ':' -f 1 $tmp`
ligne=$[ligne+1]


sed -n $ligne'p' $last

done



elif [ $1 = '-temoin' ] 
then
grep -n 'reboot' $last > $lastReboot

i=1
ligne=0


sed -n '1p' $lastReboot >$tmp


ligne=`cut -d ':' -f 1 $tmp`
ligne2=$[ligne-1]
 
heures=`sed -n $ligne'p' $last  | cut -d ':' -f 1 | tail -c 3`
minutes=`sed -n $ligne'p' $last  | cut -d ':' -f 2 | cut -c -3`

if [ $minutes > 39 ]
then
heures=$[(heures+1)%24]
fi


i=0

while  [ `sed -n $ligne2'p' $last  | cut -d ':' -f 3 | cut -c -3` -lt  $[(minutes+30)%60]  -a `sed -n $ligne2'p' $last  | cut -d ':' -f 3| cut -c -3` -eq $heures -a  $ligne -lt `tail -n 1 $lastReboot | cut -d ':' -f 1` ] 
do
i=$[i+1]
sed -n $ligne2'p' $last
ligne2=$[ligne2-1]
done




fi 



fi


#partie 2

#sed -re 's/;/!/g' fichier
#sed -re 's/^t/T/g' fichier
#sed -re 's/ \//,/g' fichier
#sed -re 's/\//+/;s/;/@/g' fichier
#sed -e '2d;3d;4d; ' fichier





