bash脚本语法错误" DO"? [英] Bash script syntax error "do"?
本文介绍了bash脚本语法错误" DO"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#!/bin/sh
for repo in repoA, repoB, repoC;
do
echo Cloning $repo.
done
当我执行这个( SH myscript.sh
)我得到以下几点:
When I execute this (sh myscript.sh
) I get the following:
myscript.sh: line 2: syntax error near unexpected token `$'\r''
'yscript.sh: line 2: `for repo in repoA repoB repoC;
想法?
推荐答案
Windows使用两个字符的每一行的末尾:'\\ r'
和的'\\ n'
。 Unix的只是使用的'\\ n'
。 presumably你在记事本编辑这一点,并在Cygwin的,这就是为什么你得到这个错误运行它。
Windows uses two characters at the end of each line: '\r'
and '\n'
. Unix just uses '\n'
. Presumably you're editing this in notepad and running it in cygwin, which is why you're getting this error.
下载记事本+ + 编辑器,它具有在<$ C为UNIX风格的行尾选项$ C>编辑/ EOL转换。
Download the Notepad++ editor, which has an option for unix-style line endings under Edit / EOL Conversion
.
这篇关于bash脚本语法错误&QUOT; DO&QUOT;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文