top with progame name

function ptop(){ `ps -ef | grep $* | awk 'BEGIN{printf "top "}{printf "-p" $2 " " }'` }
Sample Output
ptop apache

top - 10:42:03 up 2 days, 23:34,  5 users,  load average: 0.13, 0.17, 0.12
Tasks:  11 total,   0 running,  11 sleeping,   0 stopped,   0 zombie
Cpu(s):  4.7%us,  3.3%sy,  0.0%ni, 89.0%id,  2.7%wa,  0.0%hi,  0.3%si,  0.0%st
Mem:   1051976k total,   908604k used,   143372k free,   186776k buffers
Swap:   851960k total,       76k used,   851884k free,   374108k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                        
 8007 www-data  20   0  209m  13m 3756 S  1.3  1.3   0:00.80 apache2                        
 2675 root      20   0  205m  11m 6140 S  0.0  1.1   0:29.60 apache2                        
 7431 www-data  20   0  207m  10m 3684 S  0.0  1.0   0:01.86 apache2                        
 7960 www-data  20   0  206m 9816 3396 S  0.0  0.9   0:00.28 apache2   

By: xcwen
2012-09-13 02:43:57

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Similar Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: