|First, I don't want to be mean, but are you aware that within the Unix/Linux world, there are multiple shells? Evidently you are using the bourne shell. The code I submitted was korn shell, ksh. There is also the bash shell - run mostly on Linux - and the "C" shell, csh & tcsh, among others.|
Second, in a shell script, it's a good idea to always place the shell invocation on the first line in the first column. In your case, it's evidently:
Third, when asking a unix question in a forum, if you state what shell you are using and what unix version (AIX, Solaris, etc), you can save yourself a lot of time.