在脚本中使用set命令调试脚本
2024-09-04 00:10:46
当脚本文件较长时,可以使用set命令指定调试一段脚本。在脚本中使用set -x命令开启调式模式;使用set +x命令关闭调式模式。
例如:
#!/bin/bash
#Scriptname: greetings.sh
echo -e "Hello $LOGNAME, \c"
echo "it's nice talking to you."
echo -n "Your present working directory is: " $(pwd)
set -x #######开启调试模式(调试结束可注释此行)####
read -p "What is your name?" name
echo "Hello $name"
set +x #######关闭调试模式(调试结束可注释此行)####
echo -e "The time is 'date+%T'!. \nBye"
echo
最新文章
- Windows中搭建Redis集群
- ionic 界面数据缓存问题
- c++的引用
- 名词王国里的死刑execution in the kingdom of nouns
- eclipse-mvn打包跳过junit测试类
- 【10_169】Majority Element
- C#语法糖之Cookies操作类 asp.net
- placeholder 解决UITextField中placeholder和text文本同时显示的问题
- spark Streaming的Receiver和Direct的优化对比
- ORA-12560: TNS: 协议适配器错误 解决
- Leetcode 3Sum Closet
- C++ 头文件系列(array)
- Android studio导出配置
- ASP.NET Core + Docker + Jenkins + gogs + CentOS 从零开始搭建持续集成
- 如何在Linux中轻松删除源安装的软件包?
- Python:Selenium 1:浏览器驱动
- 查找命令which、whereis、locate
- vue2.0项目创建之环境变量配置
- html5 postMessage解决跨域、跨窗口消息传递(转)
- Microsoft Dynamics CRM service 创建,更新等操作时,注意写抛出异常时,抛出SoapException异常