Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
The problem statement, all variables and given/known data:
Hey, guys I really need some help with a project.
"Write a shell program that examines the command line arguments, counts and collects the number of options. Basically it has to collect and count the arguments that start with a "-" and the one's that don't start with a -
I know I have to use -*) and *) I am having trouble actually creating the structure
Relevant commands, code, scripts, algorithms:
The attempts at a solution (include all code and scripts):
I tried using some commands but I am not sure how case statement works
Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
SAC, San Antonio, TX Baker Unix
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
I've try using commands and it tells me it dosen't exist or i can't find that command what might I be doing wrong or do I have to structure that command in a specific way.
case "$1" in
-*) echo "Total of is $#";;
echo " Collected $@";;
*) echo "Total of non- is $#";;
echo "Collected $@";;
esac
I am not sure if this is even right but I know $# displays the total number of arguments and $@ shows the actual arguments but my results are that is showing all of them even for -*) still shows the ones without the -.
the ;; is not to separate commands, but sections of case. like a break; in C if you are familiar...
this does not count at all. you need a loop.
while [[ $1 ]]; do
case "$1" in
-*) increment a variable
something else maybe
;; # this ;; mean end of "-*" match
*) increment other variable
;;
esac
shift # this moves $1 to be next option on command line
done