compatibility problem ??!!

hi!

i have two problems with the following script who prepares a date (removes the heading zero from day if day<10) for arithmetical operations:

<script>
#!/usr/bin/sh

DAY=`date +%d`;
echo 1 - $DAY;#i.e. 06
DAY=${DAY#0};
echo 2 - $DAY;#i.e. 6
</script>

  1. every time i run this script on SunOS 5.7 (SPARC) i get a 'bad substitution' error (only) if the first line isn't blank
  2. every time i run this script on SunOS 5.6 (SPARC) i get a 'bad substitution' error (no matter if the first line in blank or not)

thanks

Change the first line to
#! /usr/bin/ksh

thank you very much! it really worked but what's the explanation?

On SunOs, /usr/bin/sh is the old Bourne shell which doesn't understand ${day#0}. That syntax originated with the Korn shell. Bash and the posix shell also understand it. It has spend to some other shells as well. But the Bourne shell was written before the syntax was invented.