I have a homework, write a program schedsim.sh with:
schedsim.sh [-h] [-c x] -i filename
In this:
-h:
print username
-c:
print x+1 (x is entered from keyboard), if don't enter x, print 1
-i:
print size of filename, filename is a name of file that entered.
My code:
#i/bin/bash/
while getopts ":hc:i:" Option
do
case $Option in
h)
whoami
;;
c) a=$OPTARG
if [ -z "$a" ]; then
a=1
else
a=`expr $a + 1`
fi
echo $a
;;
i) echo 'Size of file: Kylobytes'
ls -s $OPTARG
;;
*) echo 'sonething wrong'
;;
esac
done
However, when i call:
./schedsim.sh -c -i abc.txt
Error.
Sorry, my English is poor!