简体   繁体   English

语法错误:for循环中文件意外结束

[英]syntax error: unexpected end of file in for loop

I have a very large script, and I'm trying to introduce a for loop. 我的脚本非常大,我正在尝试引入for循环。 To test that I have the right syntax, at line 120 say, I have: 为了测试我是否具有正确的语法,请在第120行说:

for M in "1 2 3 4"; do
    echo $M
end

However I get the error: 但是我得到了错误:

./script.sh: line 120: syntax error: unexpected end of file

Even more worryingly, I get the same if I run: 更令人担忧的是,如果运行,我将得到相同的结果:

for M in $( ls ); do
    echo $M
end

What am I doing wrong here? 我在这里做错了什么?

您需要使用done not end完成for循环

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM