Stripping date fields

How would I strip a date field? For example, if I have
TODAY defined as the following: TODAY=`date +"%m/%d/%y"`,
TODAY is assigned the value 11/01/03 on Nov 1, 2003
How would I strip the first 2 bytes? (11)?

Thank you in advance for the help.

You might want to use the cut command.

You didnt mention what you wanted to use the first two chars for but if you are using Korn shell then you could use one of the builtins (which should run faster than the cut command) and set a variable equal to the first two chars. For example:

${parameter%%pattern} which deletes the longest suffix that matches the pattern. You can modify this construct to set a variable to the shortest suffix of the parameter by removing one of the percent signs: ${parameter%pattern}. Finally, you can play the same game with prefixes by using the pound sign: ${parameter##pattern} or ${parameter#pattern}

google is correct in that cut is very slow and should be used sparingly in circumstances where extracts need to occur many times. Much better to use a data processing tool such as awk for mass data extraction and manipulation.

However, I would suggest that you need to get to grips with the fundamentals of UNIX (i.e. commands such as cut) before you try to experiment with more advanced features.

To get the most out of parameter substitution as suggested by google, it is necessary to understand the principles of regular expressions (often called regexp) which underpin many of the best attributes of UNIX commands (e.g. egrep and awk)

Another way: use typeset to define attributes of a variable, eg left-justified string width=2...

typeset -L2 MM
MM=$TODAY

Thanks for all who replied. Using the "typeset" command seemed the simplest way to me. I used it, and it worked. For those who knows the system so well, thank you so much for sharing your knowledge. This is a great help for people like me, who are just getting familiar with Unix. I hope in the years to come, I would be able to return the favor for somebody else.

Thanks again.
Latha

Google wanted to know what I was using this for. We have monthend procedures, which creates reports, logs, etc. I wanted to name these files with the appropriate month code. That is where the month code came in.

Latha