I have some shell scripts written under windows. When under windows, I copy it from Notepad plus, paste it into Putty console, and they work perfectly. But they throw syntax errors if I run them in Linux.
I found that this error is caused by some special characters (M-oM-;M-?#!/bin/bash) preceding shebang. I cannot delete them. If I delete the whole shebang line, they move to the next line.
The weird thing is that only some of these scripts contain such characters but others are fine.
All these scripts were written using Notepad Plus.
Please note that neither the dos2unix command work nor deleting ^M characters at the end of line.
Thank you in advance!