【shell】shell脚本的调试方式(一)
来源:互联网 发布:图像处理滤波算法 编辑:程序博客网 时间:2024/05/22 10:23
以例子的形式进行叙述,没有添加debug代码的初始脚本如下所示:
#!/bin/sh
#set -x
echo -n "Can you write device drivers? "
read answer
answer=`echo $answer | tr [a-z] [A-Z]`
if [ $answer = Y ]
then
echo "Wow, you must be very skilled"
else
echo "Neither can I, I'm just an example shell script"
fi
注:简而言之,就是通过交互的方式输入Y,y 或者其它的字符,并将小写转为大写字母,然后打印出相应的语句。
这段脚本的输入结果如下:
$ ./example
Can you write device drivers? y
Wow, you must be very skilled
or
$ ./example
Can you write device drivers? n
Neither can I, Im just an example shell script
通过在代码中添加set -x 命令进行shell脚本跟踪,如上面红色部分所示。将#去掉,则执行脚本后输出结果如下:
$ ./example
+ echo -n 'Can you write device drivers? '
Can you write device drivers? + read answer
y
++ tr '[a-z]' '[A-Z]'
++ echo y
+ answer=Y
+ '[' Y = Y ']'
+ echo Wow, you must be very skilled
Wow, you must be very skilled
- 【shell】shell脚本的调试方式(一)
- 【shell】shell脚本的调试方式(二)
- 【shell】shell脚本的调试方式(三 )
- 【shell】shell脚本的调试方式(四 )
- Shell脚本调试的几种方式
- shell 脚本调试(使用shell的执行选项)
- shell脚本(一)
- shell脚本(一)
- shell脚本的作用,shell脚本变量的定义和三种赋值方式【shell脚本的学习笔记一】
- shell脚本的调试技巧
- Shell脚本的调试选项
- Shell脚本的调试技术
- 调试Shell脚本的技巧
- Shell脚本的调试方法
- Shell脚本的调试方法
- shell 脚本的执行方式
- 执行Shell脚本的方式
- Shell脚本的执行方式:
- Nand Flash
- PostgreSQL
- 自己对二次开发的理解
- struts2 中配置result 中chain、redirect、redirectaction的区别
- linux shell 特殊变量----轻松获取系统信息
- 【shell】shell脚本的调试方式(一)
- 简单Blog项目笔记之九:实现 全选/反选
- 跟踪多个事件
- 5102背景和多国语言的构造
- Java--第15周实验--
- QTP常用VBS函数
- oracle安装介质及补丁集下载地址
- Cscope 介绍
- Matlab符号运算总结