Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 10-04-2012, 08:46 AM   #1
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, 09:11 AM   #2
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.

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, 09:36 AM   #3
LQ Newbie
Registered: Oct 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
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
ps -A -o pid,comm | grep xxx


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 02:07 PM
grep has no effect - does not grep anything in this for loopa LinuxChiq Linux - Newbie 2 12-01-2011 09: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 10:31 PM
how to grep multiple filters with grep LinuxLover Linux - Enterprise 1 10-18-2007 07:12 AM
ps -ef|grep -v root|grep apache<<result maelstrombob Linux - Newbie 1 09-24-2003 11:38 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:10 PM.

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