国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 操作系統 > 正文

Shell調試

2024-06-28 14:31:58
字體:
來源:轉載
供稿:網友

一、簡介

本文全面系統地介紹了shell腳本調試技術,包括使用echo, tee, trap等命令輸出關鍵信息,跟蹤變量的值,在腳本中植入調試鉤子,使用“-n”選項進行shell腳本的語法檢查, 使用“-x”選項實現shell腳本逐條語句的跟蹤,巧妙地利用shell的內置變量增強“-x”選項的輸出信息等。

 

二、shell調試選項

1)只讀取shell腳本,不實際執行,用于檢測shell腳本是否存在語法錯誤

-n

 

2)使shell解釋器從一個字符串中讀取并執行shell指令,用于臨時測試小段腳本

-c "string"

 

3)進入跟蹤方式,使shell在執行腳本的過程中把它實際執行的每一個命令行顯示出來,并且在行首顯示一個"+"號

-x

示例:

$ sh –x exp2.sh+ trap 'echo "before execute line:$LINENO, a=$a,b=$b,c=$c"' DEBUG++ echo 'before execute line:3, a=,b=,c='before execute line:3, a=,b=,c=+ a=1++ echo 'before execute line:4, a=1,b=,c='before execute line:4, a=1,b=,c=+ '[' 1 -eq 1 ']'++ echo 'before execute line:6, a=1,b=,c='before execute line:6, a=1,b=,c=+ b=2++ echo 'before execute line:10, a=1,b=2,c='before execute line:10, a=1,b=2,c=+ c=3++ echo 'before execute line:11, a=1,b=2,c=3'before execute line:11, a=1,b=2,c=3+ echo endend

 

三、shell調試工具:bashdb

源碼

http://bashdb.sourceforge.net/

安裝

yum install -y bashdb

實例

http://zhangge.net/1517.html

 

參考:http://www.ibm.com/developerworks/cn/linux/l-cn-shell-debug/

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 班玛县| 乌什县| 尼木县| 克山县| 邵东县| 朔州市| 韩城市| 台南县| 焦作市| 株洲市| 桐庐县| 藁城市| 泌阳县| 桐乡市| 三门峡市| 长岭县| 晋江市| 梁山县| 邵阳市| 龙海市| 唐山市| 旬邑县| 松桃| 思南县| 和龙市| 垣曲县| 屯门区| 许昌市| 仁布县| 盖州市| 自贡市| 马鞍山市| 荔波县| 临沧市| 兴城市| 阳高县| 醴陵市| 万盛区| 监利县| 板桥市| 三江|