You could loop over the user accounts and invoke the
Here's a little script:
while read user; do
if ! last -5 "$user" | grep "^$user"; then
printf "$user\tno session found\n"
done < <(dscl . list /Users | grep -v '^_')
You could also feed multiple user names to
last user1 user2, but you wouldn't get any output unless session data exists for the user.
In the script above option
-5 is used to limit the output to the 5 (last recent) entries and
grep to make sure each line starts with the user name you're looking for. If no line is found, then
no session found is printed for the user.
Make sure you have admin rights when you run the script, otherwise the output of
last will be empty.