[英]How can I create shell command in linux like this: hh.sh filename -e -c?
The options are following the filename rather than hh.sh.选项跟随文件名而不是 hh.sh。 And the following code does not work.
并且以下代码不起作用。
while getopts ":ec" opt; do
case $opt in
e)
eflag=1
;;
c)
cflag=1
;;
esac
done
shift $(($OPTIND - 1))
what about something like this.这样的事情怎么样。
filename=$1
shift
while getopts ":ec" opt; do
case $opt in
e)
eflag=1
;;
c)
cflag=1
;;
esac
done
shift $(($OPTIND - 1))
echo $filename
echo $eflag
echo $cflag
grab the filename, then shift and run getopts?获取文件名,然后移动并运行 getopts?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.