Home > bashism, linux > Shell One-liner: psgrep

Shell One-liner: psgrep

When I want to find out specific process information, I usually use ps aux | grep PATTERN. There are several drawbacks, but the most annoying one for me are the missing coloumn headlines. Therefore, I made this little alias and put it into my global bash.bashrc file:

alias psgrep=’ps u | head -n 1; ps aux | grep -v grep | grep’

This enables a psgrep command which can be used like grep (since that is exactly what it is).



Maybe some of you know an even better way? Cheerio!

Categories: bashism, linux Tags: ,
  1. Lukas
    July 12th, 2015 at 20:40 | #1

    Given you know for which executable you are looking for, there is no need to list every process and grep for one. You can just tell ps what you are looking for:

    ps u -C $EXECUTEABLE

    Hope I can save you some CPU cycles there 😉

  2. stefan
    July 13th, 2015 at 07:11 | #2

    Right, that even works without access to the shell aliases. The drawback is, one has to know/type the full binary name. Lazy people like me probably prefer less typing.
    Let the shitty computer do the work! *whip sound* 😉

  1. No trackbacks yet.