When executing the script, an error message pops up:
/bin/sh^M: Corrupt interpreter: No that file or directory
This is because the script file is saved in DOS file format. You can open the file with vim and then perform the following operations:
Solution:
:set ff=unix
:wq