我想我的Ubuntu機器上運行一個bash script
和它給我一個錯誤:Bash腳本錯誤:「function:not found」。爲什麼會出現?
function not found
爲了測試,我創建了下面的腳本,它工作在我的筆記本電腦卻沒有關於我的桌面罰款。任何想法爲什麼?我的筆記本電腦是一個mac,如果這是相關的。
#!/bin/bash
function sayIt {
echo "hello world"
}
sayIt
這將返回的 「hello world」 我的筆記本電腦,但在我的桌面,它返回:
run.sh: 3: function not found hello world run.sh: 5: Syntax error: "}" unexpected
任何幫助將非常感激。
給了我一個:語法錯誤「(」意外 –
可悲的是,我真的不知道爲什麼我對這個問題的答案downvoted:/ –
您應該包括''在()函數的定義,但不當你調用函數 – Jacob