bad substitution error!

Hi All,

I'm building a new shell script but i'm facing a problem with one line which is giving "bad substitution" error. Please assist

script lines:

#!/bin/sh
printf "%s: " "Occurrence DATE (YYYYMMDD)"; read DATE
shortdate=${DATE#??}

o/p:

./test1: bad substitution

This command is working fine directly on the original shell environment :confused:

#DATE=20110420
#shortdate=${DATE#??}
#echo $shortdate
<<110420

I changed the interpreter to #!/bin/bash and it didn't give error but how can i overcome this if want to use the #!/bin/sh??

when i changed to /bash some commands didn't work like \n and \t ??

BR,

shortdate=`echo ${DATE} | sed 's/..//'`

You can also try

${DATE:2}

What do you mean by

?
\n and \t are not commands... AFAIK, bash is a superset of sh.