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

25 lines
578 B
Bash

#!/bin/bash
## Script permettant d'avoir le top 10 des machines de chaque utilisateur
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 -r | head | tr -s " " | cut -d " " -f 3`
for i in $utilisateurs
do
echo $i
machines=`last -a $i | tr -s " " | cut -d " " -f 2 | sort | uniq -c | sort -r | head | tr -s " " | cut -d " " -f 3`
for j in $machines
do
# if [ $j != "wtmp" ]
# then
# if [ $j != "" ]
# then
echo -e "\t$j"
# fi
# fi
done
done