⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kill-byname.sh

📁 Shall高级编程
💻 SH
字号:
#!/bin/bash# kill-byname.sh: Killing processes by name.# Compare this script with kill-process.sh.#  For instance,#+ try "./kill-byname.sh xterm" --#+ and watch all the xterms on your desktop disappear.#  Warning:#  -------#  This is a fairly dangerous script.#  Running it carelessly (especially as root)#+ can cause data loss and other undesirable effects.E_BADARGS=66if test -z "$1"  # No command line arg supplied?then  echo "Usage: `basename $0` Process(es)_to_kill"  exit $E_BADARGSfiPROCESS_NAME="$1"ps ax | grep "$PROCESS_NAME" | awk '{print $1}' | xargs -i kill {} 2&>/dev/null#                                                       ^^      ^^# ---------------------------------------------------------------# Notes:# -i is the "replace strings" option to xargs.# The curly brackets are the placeholder for the replacement.# 2&>/dev/null suppresses unwanted error messages.## Can  grep "$PROCESS_NAME" be replaced by pidof "$PROCESS_NAME"?# ---------------------------------------------------------------exit $?#  The "killall" command has the same effect as this script,#+ but using it is not quite as educational.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -