I want to write a bash script :
schedsim.sh [-h] [-c x] -i pathfile
Where :
• -h: print the current username.
• -c x : get an option-argument x and print out (x + 1). If no argument was found, print the default value is 1.
• -i pathfile: print the size of pathfile. The pathfile is a required argument. If no argument was found, print out an error message.
This is what I've done so far :
x=""
path=""
while getopts ":hc:i:" Option
do
case $Option in
h) echo -e "$USER\n"
;;
c) x=$optarg+1
;;
i) path=$(wc -c <"$optarg")
;;
esac
done
if [ -z "$x"] 
then
 echo -e "$x\n"
else
 echo 1
fi
if [ -z "$path"] 
then
 echo $path
else
 echo "Error Message"
 exit 1
fi
How to finish the option-argument,required-argument part and the error message part?
iwas passed, before doing any other processing:if [ -z "$i" ]..., and print a usage when it's not.