标签:art while code 为什么 ase class getopt 脚本 case
看以下的Bash脚本:
#!/bin/bash
interval=0
count=0
pid=""
while getopts "p:d:n" arg
do
case $arg in
p)
pid=$OPTARG
echo "pid: $pid"
;;
d)
interval=$OPTARG
echo "interval:$interval"
;;
n)
count=$OPTARG
echo "count:$count"
;;
\?)
echo "unkonw argument"
exit 1
;;
esac
done原来,n后面少了一个冒号。參数都要要带上一个冒号。包含在最末尾的參数。
正确的写法:
while getopts "p:d:n:" arg
标签:art while code 为什么 ase class getopt 脚本 case
原文地址:http://www.cnblogs.com/wzzkaifa/p/6747363.html