Here is a simple example to find PID of ssh-agent for username without showing PID of grep process itself:
ps xu | grep "${USER}.*[ ]/usr/bin/ssh-agent" | awk '{print $1 $2;}' If you want for example to kill ssh-agent for current user you might use following command:
kill `ps xu | grep "${USER}.*[ ]/usr/bin/ssh-agent" | awk '{print $2;}'` To create a handy alias add to your ~/.bashrc or ~/.zshrc file the following code:
function function1 () { ps xu | grep "$1.*$2" | awk '{print $1" "$2" "$11;}' } alias mygrep="function1" And to use alias here are examples to force everyone to learn regular expressions:
. /etc/profile #to make alias usable mygrep ${USER} ${PROCESS_PATH} mygrep ${USER} "[f]nord" mygrep "[f]nord" mygrep ".*[s]shd" P.S. I've only tested these commands on Ubuntu and Gentoo.