![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| extract x lines after a pattern - place each result in separate file | gobi | Shell Programming and Scripting | 5 | 06-06-2008 04:03 PM |
| Separate lines in a single '|' separated line | hidnana | Shell Programming and Scripting | 3 | 03-17-2008 10:16 AM |
| If I want to separate my work to child process,what should I do? | robocup | UNIX for Dummies Questions & Answers | 2 | 08-09-2005 06:14 AM |
| Monitor does not diplay | wajidjafri | UNIX for Dummies Questions & Answers | 6 | 06-02-2005 10:06 PM |
| Does it require each x-client sould run in separate process? | ps_sureshreddi | UNIX Desktop for Dummies Questions & Answers | 0 | 02-14-2005 03:29 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
diplay user process in separate lines
hi
I m trying to display the processes of each user but its coming in one line like george wilkins PID TTY TIME CMD 7661 ? 00:00:01 sshd 7662 pts/6 00:00:00 bash i want the output to be like PID TTY TIME CMD 7661 ? 00:00:01 sshd 7662 pts/6 00:00:00 bash my code is proc=$(users) for i in $proc do echo $(cat /etc/passwd | grep "$i" | cut -d ':' -f 5) echo $(ps -u $i) done any idea how can i make it as a list thanks Last edited by mathur; 10-28-2008 at 07:36 AM.. |
|
||||
|
for i in `users`
do cat /etc/passwd | grep \^"$i:" | cut -d ':' -f 5 ps -u $i done i.e. Put the output to standard output rather than into a shell variable. The modified grep gives an exact match on username in the first field in passwd (e.g fred and freddy won't gove false matches). |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|