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