Skip to content

Instantly share code, notes, and snippets.

@honbin
Created June 12, 2014 10:31
Show Gist options
  • Save honbin/bd7c6aa6b8acbb70e2ac to your computer and use it in GitHub Desktop.
Save honbin/bd7c6aa6b8acbb70e2ac to your computer and use it in GitHub Desktop.
プロセス殺したいとき
#!/bin/bash
PS=`pgrep -lf "${1:?引数に殺したいプロセス名を渡してね}"`
echo $PS
if [ -z "${PS}" ]; then
echo "殺したいプロセス名は存在しないようですね、ウィー"
exit 1
fi
echo "これらのプロセスを殺してもよろしいですか? [Y/n]"
read ANSWER
case `echo $ANSWER | tr y Y` in
"" | Y* ) {
pkill -f "${1}"
echo "ヒーハー!!"
};;
* ) echo "フー!!";;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment