Permalink
Browse files

getMostFrequentUser: get the user with the highest login time on a ma…

…chine
  • Loading branch information...
1 parent 122c992 commit a8f6df5b5c97b7af5443ea1f369668e8cf57a59c @timsutton committed Jun 26, 2012
Showing with 7 additions and 0 deletions.
  1. +2 −0 getMostFrequentUser/README.txt
  2. +5 −0 getMostFrequentUser/getMostFrequentUser.sh
@@ -0,0 +1,2 @@
+This one-liner retrieves the username of the user with longest time logged in, using the
+UNIX ac command.
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+#ac -p | awk 'END {print NR }'
+
+ac -p | awk '!/total/' | sort -rnk 2 | awk '{print $1}' | head -n 1

0 comments on commit a8f6df5

Please sign in to comment.