Unix与OS X脚本实用指南
1. renicename脚本
1.1 代码展示
#!/bin/bash # renicename--Renices the job that matches the specified name user=""; tty=""; showpid=0; niceval="+1" # Initialize while getopts "n:u:t:p" opt; do case $opt in n ) niceval="$OPTARG"; ;; u ) if [ ! -z "$tty" ] ; then echo "$0: error: -u and -t are mutually exclusive." >&2 exit 1 fi user=$OPTARG ;; t ) if [ ! -z "$user" ] ; then echo "$0: error: -u and -t are mutually exclusive." >&2 exit 1 fi tty=$OPTARG ;; p ) showpid=1; ;; ? ) echo "Usage: $0 [-n niceval] [-u user|-t tty] [-p] pattern" >&2