Remove characters from string variable

I am running a script where one of the variables (the month and year) is input at the command line. What I would like to do is chop off the last few characters of that string to create a new variable, while maintaining the old one.

The script is run like this:
./pull_station_v4.csh KYWST 09_2008

The 09_2008 (MM_YYYY) is what I am trying to change.

I have tried using the sub functions with sed and awk, but I am having difficulty passing the original variable (I guess it would be called ${2} since it is input at the command line when calling the script) into those functions.

This is the code I have now, but this seems to be throwing my script into an infinite loop:

awk BEGIN {
newmonth = $2
split (newmonth,array,"_2")
} END

Thank you for your help.

It looks like you want the month. Assuming bash shell.
bash version:

mmyy="$2"
month=${mmyy:0:2}
year=${mmyy:3}

Thank you for your help, but I am using Tenex C-Shell, not bash.

I am looking for just the month - though in the original variable, there is an underscore between the month and year.

I should avoid to write scripts in csh, anyway with

awk:

awk -F_ '{print $1}'

sed:

sed 's/_.*//'