ps avg | grep ? filter the desired out put.


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users ps avg | grep ? filter the desired out put.
# 1  
Old 04-01-2009
ps avg | grep ? filter the desired out put.

Hi Folk,

Following is the command I used to get data related to the DataFlowEngine.
I wanted to know the % usage of cpu and memory.
Code:
ps avg | grep Data

This command will show the processes with its PID as :
Code:
PID   TTY  STAT  TIME   PGIN SIZE  RSS    LIM  TSIZ   TRS %CPU %MEM COMMAND 
  303248   - A    306:32  378 96628 77420    xx    20    56    0.0  0.0           DataFlo
  315404   - A     7:52   109 77944 51104     xx    20    56    0.0  0.0         DataFlo
  426060    - A    230:41  16 100196 100252  xx    20    56   0.1  0.0          DataFlo


Now I want the further details related to that PID that I can get after searching in ps -elf table.

How to use the output of above given command (ps avg | grep Data) as input to the ps -elf and then filter the PID and Process Name using one line command?
If script then it would be ok as well.
I know we can use awk or sed command to filter that.

Last edited by Yogesh Sawant; 04-07-2009 at 05:33 AM.. Reason: added code tags
# 2  
Old 04-10-2009
Code:
for DATAPID in `ps -avg | grep Data | awk '{ print $1 }'`; do
 ps -elf | grep ${DATAPID} | grep -v grep
done

Not an elegant one-liner but it might provide what you are after.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Grep -P does not capture the desired output

Hi, I'm trying to filter the following output to only display information about an alarm where the Status: corresponds to Set. -------------------------------------------------------- Description: hw_optics: RX POWER LANE-0 LOW ALARM Location: Optics0/0/0/21... (6 Replies)
Discussion started by: sand1234
6 Replies

2. Shell Programming and Scripting

Filter pattern in grep command

Hi, I am having a file like below hello how are you hello... (5 Replies)
Discussion started by: rohit_shinez
5 Replies

3. Shell Programming and Scripting

Grep regex filter

Hi, How can I run the grep search in a script to only include compute, not bigcomputer in following search input? " properties = local compute" " properties = local bigcompute" Thank you. -j (6 Replies)
Discussion started by: hce
6 Replies

4. Shell Programming and Scripting

ls | grep (i dont know what to put here)

Dear users, I googled for a while, but i have got a lot of different answers regarding a simple unix command. lets say there are a lot of files in a directory. How can i list the files in a directory whose file types is "text"? Thank you in advance (4 Replies)
Discussion started by: kevincobain2000
4 Replies

5. UNIX for Advanced & Expert Users

filter last 24 hour data and put in new file

i have file server 1 (filesvr01acess.log) and disc server 1 (discsvr01acess.log) in unix box(say ip adress of the box 10.39.66.81) Similiarly i have file server 2 (filesvr01acess.log) and disc server 2(discsvr01acess.log) in another unix box(say ip adress of the box 10.39.66.82). Now my... (1 Reply)
Discussion started by: nripa1
1 Replies

6. Shell Programming and Scripting

Filter on a grep

I am attempting to figure out how to only capture part of a grep command I am doing. So far no luck. When I execute.... leviathan:/gfs/home/tivoli>ps -ef | /usr/ucb/ps -auxww | grep nco_p_syslog The results are.... tivoli 10185 0.0 0.0 5888 5168 ? S Oct 23 0:26... (2 Replies)
Discussion started by: LRoberts
2 Replies

7. Shell Programming and Scripting

filter grep command

I have ran into a small issue and I am not sure how to fix it. In one of our current scripts we have this line which does a grep to get the pid of the process. ps -ef | grep nco_p_syslog | grep $x | awk '{print $2}' However this is not returning anything due to the how long the value... (7 Replies)
Discussion started by: LRoberts
7 Replies

8. Shell Programming and Scripting

Grep script to filter

Hi, Wondering if anyone could help me with a simple script to filter out multiple things from a file. Right now I just have long lines of grep -v remove file | greg -v etc etc What I would like to do is have grep -v <run everything in a file> tofilter If that makes sense. Basically a... (2 Replies)
Discussion started by: kevin9
2 Replies

9. Solaris

How to grep (say)last-3 and next-3 lines of Desired Pattern

Hi All, OS-Type=Sun-OS 5.8 Sparc9 Processor Can I grep the previous 4 lines and next 4 lines of a matched pattern(context grep)? For example here we need to monitor logs of live traffic.The data obtained from "tail -f LiveTrafficData.log" looks something like this:-... (3 Replies)
Discussion started by: Sujan Banerjee
3 Replies

10. Shell Programming and Scripting

Put the output of grep in a variable

Hi, in a shell script how can I put the result of a grep command in a variable : myvariable=grep mystring myfilename Thank you. (3 Replies)
Discussion started by: big123456
3 Replies
Login or Register to Ask a Question