1. 程式人生 > >跑shell指令碼出錯問題以及解決。

跑shell指令碼出錯問題以及解決。

指令碼資訊:

#!/bin/bash
function hello(){
cat <<YJT
  echo "hello world!!!"
YJT 
}
hello 

錯誤:

test.sh: line 7: warning: here-document at line 3 delimited by end-of-file (wanted `YJT')
test.sh: line 8: syntax error: unexpected end of file

解決:

        是由於在末尾的YJT後面有空格導致的,YJT這個結束符的前面都不應該有空格,否則就會報錯。