cours0809/cours/S5A/TP/top10/top10.sh~

18 lines
444 B
Bash

#!/bin/bash
## Script permettant d'avoir le top 10 des utilisateurs ayant le plus grand nombre de connexions à cette machine
echo "Traitement en cours ..."
nombre_ligne=`last | wc -l`
nombre_reel=$(expr $nombre_ligne - 1 )
utilisateurs=`last | cut -d " " -f 1 | head -n $nombre_reel | sort | uniq -c | sort -rn | head | tr -s " " | cut -d " " -f 3`
for i in $utilisateurs
do
if [ $i != "reboot" ]
then
echo -e "$i"
fi
done