@Jasen's elegant answer inspired me to think of this variation, also requiring GNU date:
#!/bin/sh D=${1-10152015} YYYY=${D#????} MMDD=${D%????} date -d"$YYYY$MMDD yesterday" +%m%d%Y This uses the POSIX compliant Parameter Expansion substring processing with pattern matching notation, thus also runs under /bin/sh (assuming /bin/sh is aany POSIX shell, on Solaris 10 and below, use /usr/xpg4/bin/sh) as well as bash. It still assumes GNU date.
This could also be accomplished without the intermediate variables YYYY and MMDD, but I think they help to clearly document the input and output formats. They give the observer an extra symbolic clue about what's being done, without the addition of extra logic. Especially helpful because I think this notation is slightly more cryptic than the bash version.