任何语编程都有对应的调试工具,如java有Debug、mysql有调试工具、js有调试工具等,shell也不例外
shell的语法检测:(相当于java的编译)
1、shell语法检测:
sh -n ./test.sh (sh是/bin/sh 是系统提供的可执行脚本)
执行没有出现内容这说明语法没有错误
2、shell的普通调试:
sh -x ./test.sh
如tes.sh的内容如下:
#!/bin/bash
echo "welcome to shell debug"
for i in 1 2 3 4 5
do
echo $i
done
echo "shell debug is over"
执行sh -x ./test.sh该语句后如下:
[root@hadoop01 shell]# sh ./tes.sh
welcome to shell debug
1
2
3
4
5
shell debug is over
[root@hadoop01 shell]# sh -x ./tes.sh
+ echo &#