我认为echo关键字没有语法,也就是说,我们可以使用"或',或者没有引号。
我在bash shell中尝试了这三种类型。
我搞错了。为什么会发生这种事?
{#Azar's first shell script
echo "Hi Azar, Welcome to the new world of technology for you"
echo 'default script bash'
echo keep going don't stop always}错误:
sh afs.sh
Hi Azar, Welcome to the new world of technology for you
default script bash
afs.sh: 6: afs.sh: Syntax error: Unterminated quoted string发布于 2017-02-26 04:34:45
您的脚本失败时,您正试图
echo keep going don't stop always在语法错误中说明了原因
Unterminated quoted string因为在'中使用don't,所以Bash一直在寻找另一个关闭句子的'。由于从未找到语法错误,因此将打印语法错误。
在这种情况下,您需要像这样使用双引号(“")
echo "keep going don't stop always"一般情况下,在打印某物时,建议使用引号。在双引号中,您可以使用',如果需要,可以在单引号中使用"。
发布于 2017-02-26 05:13:28
https://askubuntu.com/questions/887366
复制相似问题