The problem is probably that /bin/sh not the same as or does not behave the same as your normal shell. For example, when bash is called as /bin/sh , it provides a subset of its usual functions.
So, you may need to change your shebang line to use a different shell:
#!/bin/bash
or
#!/bin/ksh
You do not need half-columns at the ends of the lines.
Jonathan leffler
source share