用 Bash 写的脚本也可以进行调试,和 Python,Perl 等解释型语言一样。新建一个名为 servinfo 的脚本并增加可执行权限:
#!/bin/bash
echo "Hostname: $(hostname)" echo "Date: $(date)" echo "Kernel: $(uname -mrs)"
$ chmod +x servinfo
echo "Hostname: $(hostname)" set -x echo "Date: $(date)" set +x echo "Kernel: $(uname -mrs)"