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.