|
|
|
|
google site
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Users | 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. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|||
|
Operating on each of the individual outputs of a command
Code:
ps -e -o pcpu,pid,cmd --sort pcpu | sed '/^ 0.0 /d'|awk '{print $2}'|grep -v PID
Gives the output: Code:
4482 4023 5912 I want to operate on each pid in the output. How to do so. |
| Sponsored Links |
|
|
|
||||
|
Quote:
Code:
for PID in $(ps -e -o pcpu,pid,cmd --sort pcpu | sed '/^ 0.0 /d'|awk '{print $2}'|grep -v PID)
do
echo "the PID is $PID" # or whatever you want to do with that PID
done
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Assigning variable from command outputs to shell | staze | Shell Programming and Scripting | 2 | 06-28-2009 12:40 AM |
| Trouble with tee command to capture script outputs | muthubharadwaj | Shell Programming and Scripting | 5 | 02-16-2009 08:29 PM |
| recording command outputs in background | jehrome_rando | Shell Programming and Scripting | 2 | 02-16-2009 05:13 PM |
| Need help operating the "vi" command remotely | Terrible | UNIX for Advanced & Expert Users | 4 | 06-13-2006 12:54 PM |