更新时间:2022-06-09 08:27:21
请确保您的第一行是:
#!/bin/bash
输入您的路径来砸如果不是 /斌/庆典
Enter your path to bash if it is not /bin/bash
尝试运行:
dos2unix script.sh
这WIL转换行尾等从Windows到UNIX格式。也就是说,它去掉从行结束符\\ R(CR),将它们从更改\\ r \\ n(CR + LF)
到 \\ n(LF)
。
That wil convert line endings, etc from Windows to unix format. i.e. it strips \r (CR) from line endings to change them from \r\n (CR+LF)
to \n (LF)
.
More details about the dos2unix
command (man page)
另一种方式告诉如果您的文件在DOS / Win的格式为:
Another way to tell if your file is in dos/Win format:
cat scriptname.sh | sed 's/\r/<CR>/'
输出会是这个样子:
The output will look something like this:
#!/bin/sh<CR>
<CR>
echo Hello World<CR>
<CR>
这将输出&LT整个文件文本; CR&GT;
文件中显示每个 \\ r
字符
This will output the entire file text with <CR>
displayed for each \r
character in the file.
的 P.S。很抱歉的穷人格式化,这是从我的iPhone,而开车上班书面:P 的