Skip to content

Instantly share code, notes, and snippets.

@kowntaq
Forked from kiyop/psgrep
Last active January 1, 2016 10:29
Show Gist options
  • Save kowntaq/8131501 to your computer and use it in GitHub Desktop.
Save kowntaq/8131501 to your computer and use it in GitHub Desktop.
#!/bin/sh
case $# in
2) PTN="$2"; PS_OPTS="$1";;
1) PTN="$1";;
*) echo "Usage: `basename $0` [PS_OPTIONS] GREP_REGEX_PATTERN"; exit 1;;
esac
PS_RES=`ps $PS_OPTS | grep -v "sh $0"`
echo "$PS_RES" | head -n 1
echo "$PS_RES" | tail -n +2 | grep --color=auto -ie "$PTN"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment