The options are following the filename rather than 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?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.