shell腳本的語法調試,我們使用bash的相關參數進行調試
sh [參數] 文件名.sh
- -n 不要執行script,僅查詢語法的問題
- -v 在執行script之前,先將script的內容輸出到屏幕上
- -x 將使用的腳本的內容輸出到屏幕,該參數經常被使用
#-v的示例:
[----~]$ sh -v demo.sh module () { eval `/usr/bin/modulecmd bash $*` } #!/bin/bash case $1 in "one") echo "you input number is one" ;; "two") echo "you input number is twp" ;; *) echo "you input number is other" ;; esac you input number is other
#-x的示例: [--- ~]$ sh -x demo.sh + case $1 in + echo 'you input number is other' you input number is other