Você pode usar o comando ac
para isso. Parte do pacote psacct
.
$ last|head
steve pts/0 cpc79909-stkp12- Tue Nov 20 18:40 still logged in
steve pts/0 cpc79909-stkp12- Mon Nov 19 22:19 - 23:09 (00:50)
steve pts/0 cpc79909-stkp12- Wed Nov 14 19:36 - 19:45 (00:09)
steve pts/0 cpc79909-stkp12- Fri Nov 9 11:43 - 11:56 (00:12)
steve pts/0 cpc79909-stkp12- Thu Nov 8 21:58 - 22:00 (00:02)
steve pts/0 cpc79909-stkp12- Mon Nov 5 17:37 - 18:30 (00:53)
steve pts/0 cpc79909-stkp12- Fri Nov 2 19:45 - 20:39 (00:54)
steve pts/1 cpc79909-stkp12- Fri Nov 2 17:34 - 18:31 (00:57)
steve pts/0 cpc79909-stkp12- Fri Nov 2 16:01 - 18:30 (02:29)
steve pts/0 cpc79909-stkp12- Thu Nov 1 21:10 - 23:14 (02:04)
$ ac -p
steve 33.79
total 33.79
$
Ou use awk
?
$ last | awk '$NF ~ /^\([0-9]+:[0-9]+\)$/{split($NF,t,":");a[$1]+=t[1]*60+t[2]}END{for(x in a){print x,a[x]}}'