Skip to content

Instantly share code, notes, and snippets.

@kiyop
Created July 25, 2013 09:03
Show Gist options
  • Save kiyop/6078056 to your computer and use it in GitHub Desktop.
Save kiyop/6078056 to your computer and use it in GitHub Desktop.
ps して grep するスクリプトを検索するといろいろ出てくるけど、個人的にはこれで十分なので
#!/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 -n1
echo "$PS_RES" | grep --color=auto -ie "$PTN"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment