Skip to content

Instantly share code, notes, and snippets.

@benhamill
Created February 21, 2012 05:20
Show Gist options
  • Save benhamill/1873929 to your computer and use it in GitHub Desktop.
Save benhamill/1873929 to your computer and use it in GitHub Desktop.
List processes that match a string.

I named this file psg and put it in a place where my PATH could find it. You could do that, too. Also, you'll want it to be executable: chmod +x /path/to/psg.

#!/bin/bash
if [[ -z $1 ]]; then
echo -e "Usage: psg pattern\n\nShow processes whose name matches the pattern."
else
pid_list=$(pgrep -d, $1)
if [[ -n $pid_list ]]; then
ps up ${pid_list}
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment