How do I get a list of users(given from the command line) with grep and output if they are logged/work or not ?
How to get all Users and echo if they work or not?
grep;echo
 perl -le 'print while $_=getpwent' | sortWill give you the list of user names. ps -eo user= | sort -uWill give you a list of user names whose corresponding uids are the effective user ids of at least one process running. who | awk '{print $1}' | sort -uWill list the users currently logged in printf '%s\n' $@ | sort -uWill list the users passed as argument to your script.Now that you have those 4 lists, you can use the comm command to select which of those are common to any two given lists or appear in one but not the other.With a shell supporting process substitution, you can also do without creating temp files.For instance:#! /bin/bash -comm -12 <(printf '%s\n' $@ | sort -u) \         <(ps -eo user= | sort -u)Called as:./my-script root mythul stephanewill report which of those 3 users have running processes (assuming there's a one-to-one relationship between username and uid on your system).