The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
same file being opened by two users at a time paresh n doshi UNIX for Advanced & Expert Users 3 01-01-2009 03:04 PM
Processes and Users barbus Shell Programming and Scripting 22 10-03-2007 08:09 PM
users and there processes iago UNIX for Dummies Questions & Answers 3 09-10-2007 03:51 PM
Command to find last time file was opened sbr262 UNIX for Dummies Questions & Answers 3 07-18-2007 03:23 PM
How Can I Have Top Display The Top 20 Processes?? TRUEST UNIX for Dummies Questions & Answers 1 05-23-2003 09:24 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-02-2009
gabibyte gabibyte is offline
Registered User
  
 

Join Date: Nov 2009
Posts: 3
How to display what processes, users have opened at a given time

Hello,

What i have to do is make a top 10 list of users sorted by the number of processes opened at a given time. Can anyone help me with finding out for a given moment, for all users how many processes each had opened?
  #2 (permalink)  
Old 11-02-2009
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,814

Code:
who | awk '{print $1}' > t.sed; ps -ef | grep -f t.sed | awk '{arr[$1]++} END{ for (i in arr){print arr[i], i}}' | sort -rn

If this is homework, your prof is not likely to believe you wrote this...
  #3 (permalink)  
Old 11-02-2009
gabibyte gabibyte is offline
Registered User
  
 

Join Date: Nov 2009
Posts: 3
And he really doesn't

But i am now trying to disect the line and to figure out what you wrote there
  #4 (permalink)  
Old 11-02-2009
TonyLawrence TonyLawrence is offline
Registered User
  
 

Join Date: Sep 2007
Location: SE Mass
Posts: 151
You could also start with "lsof" and (with some filtering and sorting, of course) have a lot more information about what the processes are actually doing. If it's just a homework assignment, doing something interesting with that should really impress your prof :-)
  #5 (permalink)  
Old 11-02-2009
gabibyte gabibyte is offline
Registered User
  
 

Join Date: Nov 2009
Posts: 3
who | awk '{print $1}' > file.txt
sort file.txt | uniq > file.txt
echo ' ' > results.txt
w > file2.txt
for i in `cat file.txt`
do
x=`grep -c $i file2.txt`
echo $x $i >> results.txt
done
sort -r results.txt > results2.txt
head -10 results2.txt > results.txt


This was my version and my teacher suggested i do it in one line.
So it's back to the drawing board
  #6 (permalink)  
Old 11-02-2009
pludi's Avatar
pludi pludi is online now Forum Staff  
Moderator
  
 

Join Date: Dec 2008
Location: .at
Posts: 1,972
I'm sorry, but for homework questions there's a special subforum. If your question hasn't already been answered, please repost there.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:05 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0