Unix/Linux Go Back    


UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

ps avg | grep ? filter the desired out put.

UNIX for Advanced & Expert Users


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 04-01-2009
varungupta varungupta is offline
Registered User
 
Join Date: Feb 2007
Last Activity: 15 July 2010, 5:53 AM EDT
Location: Pune, Dehradun (INDIA), Michigan(US)
Posts: 206
Thanks: 0
Thanked 1 Time in 1 Post
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 04:33 AM.. Reason: added code tags
Sponsored Links
    #2  
Old Unix and Linux 04-10-2009
TonyFullerMalv's Unix or Linux Image
TonyFullerMalv TonyFullerMalv is offline Forum Advisor  
Registered User
 
Join Date: Sep 2008
Last Activity: 1 July 2013, 6:45 PM EDT
Location: Malvern, Worcs. U.K.
Posts: 1,033
Thanks: 0
Thanked 8 Times in 8 Posts

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.
Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Grep script to filter kevin9 Shell Programming and Scripting 2 02-21-2009 12:59 AM
How to grep (say)last-3 and next-3 lines of Desired Pattern Sujan Banerjee Solaris 3 11-06-2008 04:01 AM
Desired Format ! prasanth_babu HP-UX 1 02-20-2008 09:31 AM
grep a log file to filter previous dates pinpe Shell Programming and Scripting 5 08-03-2007 01:25 PM
Filter results through pipe with grep ckandreou UNIX for Dummies Questions & Answers 1 07-10-2006 02:04 PM



All times are GMT -4. The time now is 07:49 PM.