Users Not Logged in

I have searched the forums but have not mangaed to quite find what im looking for. I have used to /etc/passwd command to present me a list of all users the who command to present all users currently logged on, but what i want to know is what command can i use to display users that are registered but not currently logged in?

Please state your Operating System and version and preferred Shell in questions.
There is no generic unix command to show who has an account but is not logged in. There are enhanced versions of "finger" on some unixes but this is non-standard.

We can subtract "who -u" from "logins". We could equally use "listusers" instead of "logins" or even read /etc/passwd directly.
For example:

#!/bin/ksh
# Who is logged in now?
who -u | awk '{print $1}' >/tmp/who_u.$$
# Who has an account?
logins | awk '{print $1}' > /tmp/logins.$$
# Users who appear in "logins" but not in "who -u"
cat /tmp/logins.$$ /tmp/who_u.$$ | sort | uniq -u | pg
# Clean up temporary files
rm /tmp/logins.$$
rm /tmp/who_u.$$
who | cut -d ' ' -f1 > whoson
cut -d: -f1 /etc/passwd | grep -vf whoson

Cool cfajohnson.
No offence. OK for low numbers of users. Bit heavy on a large system.

It can be done with standard commands.

$ logins
-bash: logins: command not found

UUOC.

Sort will be slow on a large system, and it's not needed.

bash: pg: command not found

You don't need two calls to rm:

rm /tmp/logins.$$ /tmp/who_u.$$

To: cfajohnson
warlock129 has not stated his Operating System and preferred shell.
What Operating System are you running which does not have unix "pg" or "logins"?
BTW. This is "www.unix.com" and has Linux sub-forums.

On a 1000 user system with 500 users logged in I reckon that one sort of 1500 lines will beat 1000 grep's of a 500 line file.

That is irrelevant. All solutions should use a POSIX shell and standard commands.

The logins command is not available on Mandriva, Red Hat, FreeBSD or NetBSD.

The pg command is on NetBSD, but not the others.

Neither command is part of the POSIX specification.

Why would you use non-standard commands when there are standard ones that do the job?

In a forum where people have many different systems, the only sensible thing is to post solutions that work for all of them.

To: cfajohnson
At a high level, are you validating you posts against unix or Linux?

My solutions, unless otherwise noted, are POSIX compliant, which means they work on all varieties of Linux and Unix.

Whilst I admire the long-running POSIX dream, there are people out there running proprietary or legacy systems. We need to ascertain the environment before providing a solution.

It's not a dream, it's a fact.

There are very few legacy systems, probably a fraction of 1 percent.

Proprietary systems are all POSIX compliant.

The vast majority of POSIX-compliant scripts will also run on the vast majority of legacy systems because the POSIX standard was based on existing practice. The environment is only relevant for a diminishingly minute number of queries.

I wish that were true. It would make my life so much easier! Good night.

I'm running windows xp and im using the Unix bash shell should have supplied this information at the start