Sponsored Content
Top Forums UNIX for Dummies Questions & Answers [Solved] Using w; how to list find all the users Post 302730775 by alister on Tuesday 13th of November 2012 03:42:35 PM
Old 11-13-2012
Quote:
Originally Posted by samnyc
Code:
w |more
 16:06:52 up 568 days, 21:26, 75 users,  load average: 0.07, 0.10, 0.05
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
sak pts/1    :37.0            21Feb12 263days  0.18s  0.18s -csh
apr pts/3    -                Tue18    4days  0.07s  0.07s -bin/tcsh
sshe  pts/4    -                18Oct12 25days  0.00s  7:34  kdeinit: kded 
xzha   pts/6    -                Fri17    0.00s  0.69s  0.58s -bin/tcsh
xzha   pts/7    -                Wed10    5days  0.00s 10.63s kdeinit: kded 
peter    pts/9    :24.0            13:45    2:20m 52.80s  0.09s -csh
sshe  pts/12   -                19Oct12 24days  0.15s  0.03s -bin/tcsh
sshe  pts/13   -                19Oct12 24days  0.00s  7:39  kdeinit: kded 
sshe  pts/15   -                19Oct12 24da

Quote:
Originally Posted by bipinajith
Code:
w | awk '!/PCPU/ && !/days/ { print $1 } ' | sort -u

That's not a reliable approach. If all of a user's sessions have been idle for a while, they will not be listed because !/days/ would exclude them all. The same condition will also exclude any sessions currently running a command line which includes "days". Any username in which the string "days" appears is also similarly doomed.

Similar issues apply to the use of !/PCPU/.

In my opinion, a much more robust solution would specifically exclude the header:
Code:
w | awk 'NR>2 {print $1} | sort -u

Regards,
Alister
These 2 Users Gave Thanks to alister For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

su - user... how to find out the list of users and their passwords..

hi, to do a su - user, we need to know what are the users... so in unix 1) which file to see the list of users, passwords? (2 Replies)
Discussion started by: yls177
2 Replies

2. UNIX for Dummies Questions & Answers

Find users using system(List them only once)

Hey, got a few questions here for anyone who can help...... Command line to - display users using the system, but count them only once. Command line to - use the lastcomm command to display how many times ive used grep in october. Command line to - list all logged on users with at least 6... (3 Replies)
Discussion started by: xBuRnTx
3 Replies

3. UNIX for Dummies Questions & Answers

How do i find out the list of users whose terminal is writable?

Hello, i just wanted to know how do i find out the list of users whose terminal is writable?i mean i used who -T but this gives a list of all users whose terminal is writable or blocked and not writable. So how do i do this?I am new to Unix. (2 Replies)
Discussion started by: salman4u
2 Replies

4. Shell Programming and Scripting

Find Usage solved

How can I find the biggest file in a branch? I tried find / \*.\* | xargs du | sort -n 1,1 | head 1 but shell do nothings :( ---------- Post updated at 03:07 PM ---------- Previous update was at 02:41 PM ---------- Solved: find / -name \*.\* | xargs du | sort -nr | head -n 1 (0 Replies)
Discussion started by: Guccio
0 Replies

5. UNIX for Advanced & Expert Users

list of users

Hello!Does anybody know how to solve this script: ,,write a shell script which displays a list of names of users who have created files "*. c" in the last day."? (1 Reply)
Discussion started by: theodoraa
1 Replies

6. UNIX for Advanced & Expert Users

[Solved] mpathadm list lu no output

When I try to configure my HBA ports on Solaris 10; I cant see any output. bash-3.2# mpathadm list lu bash-3.2# I checked /kernel/drv/fp.conf file. ... mpxio-disable="no"; ... What shall I check more? what shall I do? ---------- Post updated at 10:18 AM ---------- Previous update was... (0 Replies)
Discussion started by: hubatuwang
0 Replies

7. Shell Programming and Scripting

[solved] Problem with find

hi All, I am using the command find /home/mqm/check/ -mtime +1|wc -l to get a count of the files older than a day under the check directory. But instead of getting the count of the files under check directory I m getting a count including the check directory itself. Can someone please tell... (0 Replies)
Discussion started by: jayii
0 Replies

8. UNIX for Dummies Questions & Answers

Users list

Hi i would like to know were the folder that contain file with list of all users ? And were i can learn about what kind of folder i have and wheat they have inside? question 2. when i write ls -a i see all directories and then i choose for example Documents and inside Documents i typed again... (1 Reply)
Discussion started by: iliya24
1 Replies

9. UNIX for Advanced & Expert Users

Find the list of files with a set of Users

Hello all, I want to find the files for certain users. I cant make the or condition work in this instance. I've tried the code below but it didnt worked. Any input on how to get the list for all files for this users. find . -type f -user abc134 -o -user xyz345 -o bce483 -exec ls... (6 Replies)
Discussion started by: sethmj
6 Replies

10. Shell Programming and Scripting

List the Manager of Users in AD - Using list- Get-ADuser

Is there any command that can used in Linux that export usernames and their manager's name from AD using bash shell script? I know this can be done using powershell but I need to use Linux for this procedure. (2 Replies)
Discussion started by: dellanicholson
2 Replies
All times are GMT -4. The time now is 09:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy