Easily search running processes (alias).

alias 'ps?'='ps ax | grep '
Sample Output
ps? ruby

13687 s000  S+     0:06.91 ruby script/server
13693 s001  R+     0:00.00 grep ruby

56
By: fzero
2009-02-05 13:36:37

What Others Think

Interesting to find something so simple that I also created. Only difference is I used psax for the command, but yours is easier to type and makes more sense. Thanks. :)
pkkid · 662 weeks and 3 days ago
Why not: pgrep
porges · 662 weeks and 3 days ago
@porges It's just a matter of taste, really. I'm into ruby so I like asking things. :-)
fzero · 662 weeks and 2 days ago
I add in a few w's in case the command is too long and make sure grep is case insensitive alias psg='ps axwww | grep -i' Then you can search for something like the finder (Finder.app) like this. psg finder 59457 ?? S 2:35.56 /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder -psn_0_12430298
claytron · 661 weeks and 1 day ago
@porges "pgrep" only displays the PIDs. "pgrep -l" only displays the PID and process name. "ps aux" displays more info.
leper421 · 661 weeks and 1 day ago
A bash function version psg() { ps auxw | grep -i $1 | grep -v grep; }
starchox · 660 weeks and 5 days ago
Refined bash function version, omit use another grep, using square bracket trick psg() { ps auxw | grep -i $(echo $1 | sed "s/^\(.\)/[\1]/g"); }
starchox · 660 weeks and 5 days ago
A very similar thing I've been using for years: pu() { ps auxw | egrep "$1|PID" | grep -v egrep; } It retains the ps header line.
hypatiafu · 660 weeks and 4 days ago
pgrep -lf syslog 4855 /sbin/syslogd -u syslog
alexfoo · 659 weeks and 3 days ago
I've used: p() { ps auxw | grep -i $1 | grep -v grep; } For years and yes, I know the double grep is inefficient. Is the sed solution really worth it though?
ajt · 655 weeks and 5 days ago
The sed trick is more specific. With the double grep you risk matching other greps, processes with the substring 'grep' in its name/args, etc. On the efficiency side, both need an additional fork. The square bracket trick can be done in shell. psg () { ps auxw | grep \[${1:0:1}\]${1:1} ; }
funollet · 652 weeks and 5 days ago
psg() { ps auxw | grep -i '[ ]\?'"$1"; } (Having fun with backslashes and quotes...)
myname · 639 weeks and 4 days ago
Wooooow! This is awesome
yeoyeo · 48 weeks and 2 days ago
private investigator sacramento Wooooow! This is awesome
yeoyeo · 48 weeks and 2 days ago
thanks alot for this, great site! business coach
looneyhans · 34 weeks and 4 days ago
thanks alot for this, great site! business coach
looneyhans · 34 weeks and 4 days ago

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?

commandlinefu.com 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



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.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

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: