I am trying to configure the cal command to recognize the month names.
When you type: cal - you get the calander for the current month of the current year.
Is there a way of making the system recognize March, and Mar. So I could type:
cal March or cal mar and get the same response as cal.
I ws thinking on how to do this but I'm thinking it might not be able to be done.
The cal command accepts numbers for months versus names. If you want otherwise you might consider writing a wrapper script that takes the different text inputs for months, maps the text forms (mar, March, Mar, march, etc.) to the number (in this case 3) and sends it to the cal utility.
This wrapper script could be written in a few minutes, don't you think?
Neo,
I am not familar with wrapper scripts.
I was thinking a longer way of doing things would be do write a bunch of if, elifs and write something like if
if [ "$1" -eq January ]
then
cal 1 2001
fi
for getting january 2001, then fill in the rest through to december.
What do you say is this an effective way or, should I try something else.
Yes, what you are describing is a 'wrapper script' because you are wrapping script around the command(s) (in this case the cal command) to perform differently than without the wrapper. So, you are on the right track. Remember to have statements or switches "Jan" and "jan" and "January" etc. based on your project needs. Also, when you write a wrapper, if others will be using it, you might consider writing a quick man page and/or a command line help file.