linux 脚本中可以使用 set -x
调试。
set -x
有详细的日志输出,可以避免不必要的 echo
set -x 开启 set +x 关闭 set -o 查看
set -x 执行后对整个脚本有效,所以 set -x 和 set +x 常常配套使用。
set -x # activate debugging from here
w
set +x # stop debugging from here
ref: https://blog.csdn.net/li575098618/article/details/49818493