-bash: ./rwx.sh: /bin/bash^M: bad interpreter: No such file or directory

Because the script file edited in windows.
Under windows, at the end of each line is \ n \ r, and at the end of the file under linux is \ n, then you are under the windows to see the edited file is opened in linux when the end of each line will be more out of character \ r
need to use the command: sed -i 's / \ r $ //' youfilename
delete \ r characters on it

Guess you like

Origin www.cnblogs.com/zhihongli/p/11104313.html