reboot system boot 3.10.0-327.el7.x Wed Oct 26 15:12 - 22:43 (07:30)
root :0 :0 Wed Oct 5 05:01 - 05:31 (00:29)
(unknown :0 :0 Wed Oct 5 05:01 - 05:01 (00:00)
reboot system boot 3.10.0-327.el7.x Tue Oct 4 23:01 - 05:31 (06:29)
root :0 :0 Wed Oct 5 04:56 - 04:58 (00:01)
(unknown :0 :0 Wed Oct 5 04:56 - 04:56 (00:00)
reboot system boot 3.10.0-327.el7.x Tue Oct 4 22:55 - 04:58 (06:02)
considerando o detalhe acima está em um arquivo:
for i in 'awk '{print $1}' test_login |sort|uniq';
do
count='grep -c $i test_login'
sum=0;
for j in 'grep $i test_login|awk '{print $NF}'|cut -c 2-6';
do
var='echo $j | awk -F: '{print ($1 * 60) + $2}'';
sum=$((sum+var));
done
((hour=$sum/60))
((min=$sum-$hour*60))
echo "User $i logged in a total of $count times with a total of $hour:$min logged"
done
test_login: arquivo que contém log de todos os usuários.
Espero que tenha ajudado.