LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-04-2012, 09:46 AM   #1
franz01
LQ Newbie
 
Registered: Oct 2012
Posts: 2

Rep: Reputation: Disabled
ps and grep


I have a (probably) simple question... I just started using a RedHat 5.6 box and I need to display some processes with ps.

So I am using ps -ef and I get the full list

Then I try to filter with ps -ef | grep my_process_filter
but I get a not readable output...

every process is displayed with the full name and is many rows long. Since I have 30 or so processes to display I cannot understand anything from what I see on the screen.
I am trying all the ps options but so far no success: ps -e | grep... ps -aux | grep... etc.

Is there a way to format the output of the piped grep??
I am also trying with something like ps -ef | grep -c in order to get the number of processes but it doesn't work either.

Thank you in advanced for your suggestion!
 
Old 10-04-2012, 10:11 AM   #2
SecretCode
Member
 
Registered: Apr 2011
Location: UK
Distribution: Kubuntu 11.10
Posts: 562

Rep: Reputation: 102Reputation: 102
You need to format the output of ps. grep will only pass the line or not.

(You can filter processes within ps itself, but let's assume you need to use grep.)

The -f parameter to ps includes a full set of columns. If you don't want that, look at the -o option, e.g.

Code:
ps -e -o pid,comm,pcpu
Is this what you wanted? Many other things can be done with ps.

Read man cpu for all the details
 
Old 10-04-2012, 10:36 AM   #3
franz01
LQ Newbie
 
Registered: Oct 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by SecretCode View Post
The -f parameter to ps includes a full set of columns. If you don't want that, look at the -o option, e.g.
ok thanks.
it seems that I get what I want with
Code:
ps -A -o pid,comm | grep xxx
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating an alias in ksh that uses grep and includes 'grep -v grep' doug248 Linux - Newbie 2 08-05-2012 03:07 PM
grep has no effect - does not grep anything in this for loopa LinuxChiq Linux - Newbie 2 12-01-2011 10:03 PM
Trying to understand pipes - Can't pipe output from tail -f to grep then grep again lostjohnny Linux - Newbie 15 03-12-2009 11:31 PM
how to grep multiple filters with grep LinuxLover Linux - Enterprise 1 10-18-2007 08:12 AM
ps -ef|grep -v root|grep apache<<result maelstrombob Linux - Newbie 1 09-24-2003 12:38 PM


All times are GMT -5. The time now is 02:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration