2016-04-30 24 views
2
#!/bin/sh 

# Define your function here 
Hello() { 
    echo "Hello World" 
} 

Hello 

上面的腳本工作正常,在ubuntu運行良好,但顯示以下錯誤 上redhat machine問題shell腳本在redhat不工作在Ubuntu

"syntax error near unexpected token ' { " 
+0

檢查:http://stackoverflow.com/questions/20895946/syntax-error-near-unexpected-token-bash – alpert

+0

你的紅帽上的哪個shell是/ bin/sh真的嗎? – Harald

+0

我已經運行以下命令cat/etc/shells中 和輸出 /bin/sh的 /斌/慶典 /sbin目錄/ nologin的 /斌/破折號 /斌/ tcsh的 /斌/ CSH –

回答

0

Ubuntu的shell是bash,但它不是炮彈錯誤監守我我使用Ubuntu和你的程序給我的O/p這樣

SH hello.sh 的Hello World