My code worked on a Mac, now it does not work in another computer

I guess Mac has default bash. Then I copy my code to another comp and run it...And it gives me an error like "bad substitution"....

How I can change my code??? Never had before this kind of situation. Help please.

if [ -f "/Users/Natalie/lastserial" ]
then
  n=$(sort /Users/Natalie/lastserial | tail -1)

  fourthoct=${n:0:4}


 thirdoct=${n:4:2}
  thirdoct=${thirdoct#0}
  secondoct=${n:6:2}
  secondoct=${secondoct#0}
  firstoct=${n:8:2}
  firstoct=${firstoct#0}

  if [ $((++firstoct)) -eq 100 ]
  then
      firstoct=0
      if [ $((++secondoct)) -eq 32 ]
      then
          secondoct=0
          if [ $((++thirdoct)) -eq 13 ]
          then
              thirdoct=0
              ((++fourthoct))
          fi
      fi
  fi

  printf  "%04d%02d%02d%02d\n" $fourthoct $thirdoct $secondoct $firstoct > '/Users/Natalie/lastserial'
else
  echo ` date +%Y%m%d`"00" >'/Users/Natalie/lastserial'
fi

What OS is the other computer?
How do you call/execute the script?

At the top of you script, include this line (right beneath the shebang line):

set -x

That turns debug mode on. When you run your script from the command line, it will execute step by step and stop where it finds an error. That will give you a clue as to what's wrong.
Do not hesitate to get back to us with the error that you find.

+ [ -f /Users/Natalie/lastserial ]
+ sort /Users/Natalie/lastserial
+ tail -1
+ n=2013101001
makedns: 10: makedns: Bad substitution

---------- Post updated at 03:30 PM ---------- Previous update was at 03:29 PM ----------

Its windows....I use sh

For windows you would want to use: Batch file - Wikipedia, the free encyclopedia
However, you could use Bash (Unix shell) - Wikipedia, the free encyclopedia for Windows, if you had installed Cygwin.

Additionaly to this weird post, i mean...
You use SH on a WinOS on a Mac... hmm....

The topic, subject, content (lost in translation) of your scripts, seems VERY MUCH similar to: Output pipes and incrementing
As in: The same homework, diffrent approaches.

Hth

Is that cygwin? Try using bash instead of sh

Cant say for sure actualy...
Been told so, though.

She wrote bash, as far as i reckognize...