Skip to content

Instantly share code, notes, and snippets.

@IanVaughan
Created April 15, 2011 08:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IanVaughan/921384 to your computer and use it in GitHub Desktop.
Save IanVaughan/921384 to your computer and use it in GitHub Desktop.
Shows via 'top' only the processes of a given name
#!/bin/bash
PIDS=`ps aux | grep "[n]ame" | awk '{print $2}'`
if [ $PIDS = "" ]; then
exit
fi
PID_LIST=
for pid in $PIDS; do
PID_LIST="-p$pid $PID_LIST"
done
top ${PID_LIST}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment