I have two variables: X and Y.
The value of X will be a date given in the format mmddyy
and I want to calculate the date preceding that date and have it be returned in in the format yyyymmdd.
Let me give you an example. When X=”091509″ (mmddyy format) Y should be “20090914” (yyyymmdd format)
And if you want to retrieve the date in a custom format you just throw in some format strings.
As for your conversion you may use bash substring extraction (assuming you use bash of course). This also assumes that your input is consistent and “safe”.
See http://www.walkernews.net/2007/06/03/date-arithmetic-in-linux-shell-scripts/