Hello, I want to write a script that takes a username as input and outputs the user's logins sorted by duration. Also I want to exclude the "still logged in" entries.
I use the "last" command but Im having problems sorting the entries based on the duration.
Can you help me?
leve pts/0 :0 Sun Jan 8 12:32 still logged in
leve tty1 :0 Sun Jan 8 12:32 still logged in
leve tty2 :0 Sun Jan 8 14:30 - 14:30 (00:00)
leve pts/1 :0 Sun Jan 8 14:29 - 14:30 (00:00)
leve pts/0 :0 Sun Jan 8 14:11 - 14:29 (00:18)
---------- Post updated at 05:41 PM ---------- Previous update was at 04:54 PM ----------
Ok I tried this and managed to sort the entries.
last leve | sort -k10
Now I just have to exclude the " still logged in" entries
I had written a perl script and was just to post it before reading your message. I did it because thought that could be difficult to process the sorting of the time in parentheses, but if that command works for you, ready.