Breaking strings into Substrings

I'm only new to shell programming and have been given a task to do a program in .sh, however I've come to a point where I'm not sure what to do. This is my code so far:

# process all arguments (i.e. loop while $1 is present)
while [ -n "$1" ] ; do
# echo "Arg is $1"

case $1 in
-h*|-H*) echo "help msg1" ; echo "help msg2" ;
shift ;;

[12][0-9][0-9][0-9]) the_year=$1 ;
shift ;;

Jan*|jan*|JAN*) the_month="Jan" ; shift ;;
Feb*|feb*|FEB*) the_month="Feb" ; shift ;;
Mar*|mar*|MAR*) the_month="Mar" ; shift ;;
Apr*|apr*|APR*) the_month="Apr" ; shift ;;
May*|may*|MAY*) the_month="May" ; shift ;;
Jun*|jun*|JUN*) the_month="Jun" ; shift ;;
Jul*|jul*|JUL*) the_month="Jul" ; shift ;;
Aug*|aug*|AUG*) the_month="Aug" ; shift ;;
Sep*|sep*|SEP*) the_month="Sep" ; shift ;;
Oct*|oct*|OCT*) the_month="Oct" ; shift ;;
Nov*|nov*|NOV*) the_month="Nov" ; shift ;;
Dec*|dec*|DEC*) the_month="Dec" ; shift ;;

*) echo "? unrecognised input: $1" ;
shift ;;
esac
done

echo "Got month: $the_month"
echo "Got year: $the_year"

oldIFS="$IFS"
count=0
IFS="/"; while read file
do
set -- $file
IFS=":"
set -- $1

    if [ "$3" = "$the_year" ]   
then
    echo $file
        count=\`expr $count \+ 1\`
    else
        if [ "$2" = "$the_month" ]
    then
            echo $file
            count=\`expr $count \+ 1\`
        fi
    fi
done < my\_sample_log2.txt

echo $count
IFS=$oldIFS

What my problem is where the IFS changes happen. I need to break the text into substrings based on field separators of "/" - only interested in the month and year patterns. Also need a counter/s which are updated according to the substrings found in the input data.

My program isn't working, and I have a feeling it is to do with two IFS changes, but I don't know how else to break the string up to just get the Month or year. The lines in the file look something like:
66.196.90.230 - - [01/Mar/2006:01:28:59 +1000] "GET /file.txt HTTP/1.0" 404 282

Thanks.

Is it homework ? Homework posts are not allowed in this forum.

Since you have quite a bit, here is a little modification that you could use.

IFS="/"; while read file
do
set -- $file
IFS=":"
set -- $1

will become

while IFS="/" read day month year rest
do
MONTH=$month
YEAR=$year

Modify the rest accordingly.

No, it isn't homework. Just something I'm trying to do to try and extend learning of shell, which isn't working very well.

Thank you for that input, however I am still having the same main issue. I can't extract the year from that sequence with just changing the IFS to /, as the year has 2006:01:28:59 +1000] "GET due to that being the next argument till the next /. That is why I was attempting to then change the IFS to a : to get just the 2006 from that substring, thus it never steps into the year if statement.

Thanks again.

Include : as a delimiter too.

while IFS="/:" read day month year rest
do
MONTH=$month
YEAR=$year

Haha. Feel so stupid now, I didn't realise you could include two delimiters in the one IFS statement. Doh. But that now works, thanks heaps and now I can do some further progress!