my friend has challenged me to this
shell program,count85, that reads the command line arguments, counts the number of
options (those arguments that start with a - , and counts the number of arguments (those
arguments that do not start with a -. (hint use case ... -*) *) )
Output all of the options on one line and all of the arguments with their counts on another line.
#!/bin/bash
# next echo to show the input
echo "here comes $*"
for i in $*
do
if echo $i | grep ^- > /dev/null
# the echo and | above is because grep looks
# for data in a file or stdin not in a variable
# grep ^- $i would not work
then
echo "$i is an option"
else
echo "$i is an argument"
fi
done
echo "done with optiontest with $*"
# summation and data passed for info only
dont know if i did it right or not
output is
here comes
done with optiontest with
is my if then else statement not correct
thanks
airmax_sk@yahoo.com