Which is the shortest way to list a running process?

Solution 1:

I think what you're asking for doesn't exist so why not write a little bash function or script that does exactly what you want?

function p {
    ps aux | awk -v s="$@" 'NR>1 && $11~s'
}

Stick that in your ~/.bash_functions (or wherever is called by ~/.bashrc) and call source ~/.bashrc to reload it and you should be able to run:

$ p firefox
oli       5992 11.2  4.2 2856240 1044104 ?     Sl   Jun17 313:56 /usr/lib/firefox/firefox

The expression will take a regex which makes it doubly handy. And p on its own will give you a full listing.

Solution 2:

Using alias & grep to filter out its own terminal process :

alias qp="ps aux | grep -E -v \"tty.*grep|pts.*grep\" | grep -m1"

If you want last/newest process:

alias qp="ps ax | tac | grep -E -v \"tty.*grep|pts.*grep\" | grep -m1"