Linux-shell腳本的調試和追蹤


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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM