First, the principle
Windows compiled files and Linux compiled file formats are not the same, resulting in Linux running shell scripts when prompted:/bin/bash^m:bad interpreter: There is no file or directory.
The reason is this:
1. When the Windows compiled files end (carriage return + line wrapping)
2. At the end of Linux compiled files (newline)
This causes the Windows compiled files to be placed on Linux with [Noeol] and [DOS] flag flags.
If you run the cat command to see more visually the file differences generated by two different operating systems, there is one more ^min the shell script file generated by Windows.
Command format: cat-a filenamecat-a windows.shcat-a linux.sh
Ii. Solutions
In the windows generated script into the VIM compilation mode, input ": Set Fileformat=unix #转换成unix格式", enter after Wq save exit.
It is now possible to run shell scripts in Linux using./window.sh or SH window.sh.
Done ~
(original) A shell script compiled under Windows can no longer work with Linux in a workaround