I’m looking for a ruby script that will use something like last to count the login frequency of each user and output it to a csv file so I can make a bar graph with most frequent logins.
I want it to save the CSV output like this:
user2,19
user6,20
user3,18
Normally last looks like this:
user3 :1001 192.1.20.17 Sun Nov 30 15:01 still logged in
user8 :1000 192.1.20.15 Sun Nov 30 10:00 - 11:52 (01:52)
user2 tty7 :0 Tue Nov 25 19:43 - 21:09 (01:25)
user0 tty7 :0 Tue Nov 25 16:46 - 18:06 (01:19)
Is there something that already does this, or how can I do this?
maybe this way:
you should check content of “” in split to be correct.
also you should check exact output of your last command – you maybe need to take some of the garbage out before writing to file 😉