-1
我有一個非常大的腳本,我試圖介紹一個for循環。 爲了測試我有正確的語法,在線路120說,我有:語法錯誤:for循環中的文件意外結束
for M in "1 2 3 4"; do
echo $M
end
但是我得到的錯誤:
./script.sh: line 120: syntax error: unexpected end of file
更令人擔憂的是,我得到同樣的,如果我運行:
for M in $(ls); do
echo $M
end
我在這裏做錯了什麼?
沒有'end'在'bash'。使用'做..做..完成'。 – sat
什麼是你的hash-bang,即第一行?如果只有擴展名,腳本可能會被解釋爲'sh'腳本而不是'bash'腳本。 – Evert
不會有意識地在'for'循環中解析'ls'的輸出,參見[ParsingLs](http://mywiki.wooledge.org/ParsingLs)。 – Inian