1.使用-x,开启shell脚本的跟踪调试功能

ex:bash -x script.sh

or

sh -x script.sh

2.使用set -x 和 set +x对脚本进行部分调试(输入中间的内容)

#!/bin/bash
#filename:debug.sh
for i in {..};
do
set -x
echo $i
set +x
done
echo "script executed"

3.固定格式生成调试信息

注:符号:告诉shell不要进行任何操作

#!/bin/bash
function DEBUG()
{
[ "$_DEBUG" == "on" ] && $@ || : }
for i in {..}
do
DEBUG echo $i
done

执行命令:_DEBUG=on ./script.sh

4.修改脚本开头#!/bin/bash 为#!/bin/bash -xv自动开启调试功能;

shell脚本使用技巧3--调试的更多相关文章

  1. shell脚本常用技巧

    shell脚本常用技巧 1.获取随机字符串或数字 ~]#echo $RANDOM | md5sum | cut -c 1-6 ~]#openssl rand -base64 4 | cut -c 1- ...

  2. shell脚本常规技巧

    邮件相关 发送邮件: #!/usr/bin/python import sys; import smtplib; from email.MIMEText import MIMEText mail_ho ...

  3. SHELL 脚本小技巧

    脚本很简单,直接上功能介绍及脚本,可以做模板使用: 记录日志,记录脚本开始执行时间.结束时间 usage 函数,脚本需接参数执行,避免误执行,告诉用户,这个脚本的使用方法 加锁,创建锁文件,脚本不允许 ...

  4. shell脚本小技巧

    输入参数错误时,退格会出现^H,这个时候只要在脚本顶部加一条语句:stty erase ^h就可以了 #!/bin/sh stty erase ^h

  5. shell脚本使用技巧5--字符分隔

    #!/bin/bash #filename:ifs.sh data="name,sex,rollon,location" oldIFS=$IFS IFS=, for item in ...

  6. shell脚本使用技巧4--读取字符,重复执行

    ls | cat -n > out.txt 给输出的信息加行号并导出到out.txt 利用shell生成一个独立的进程 pwd; (cd /bin; ls); pwd; 开启一个子shell,不 ...

  7. shell脚本使用技巧2

    0--stdin标准输入 1--stdout标准输出 2--stderr标准错误 重定向 echo "this is a good idea " > temp.txt tem ...

  8. Shell脚本小技巧收集

    1.使用python快速搭建一个web服务器 访问端口8000 python -m SimpleHTTPServer 2.获取文件大小 stat -c %s $file stat --printf=' ...

  9. shell脚本使用技巧7--cat

    cat是单词concatenate缩写 echo 'text through stdin' | cat - file.txt 输出:text throgh stdin 和file.txt中的内容: c ...

随机推荐

  1. mysql的innodb存储引擎

    innodb是支持事务的存储引擎,支持ACID特性的ACID(指数据库事务正确执行的四个基本要素的缩写) 包含:原子性(Atomicity).一致性(Consistency).隔离性(Isolatio ...

  2. spring boot引入json,jsonobject,需要指定jdk15

    spring boot引入json,需要指定jdk15 <dependency> <groupId>net.sf.json-lib</groupId> <ar ...

  3. nodejs 环境安装

    参考网站 http://www.runoob.com/nodejs/nodejs-http-server.html https://github.com/nodesource/distribution ...

  4. Web的几种上传方式总结

    问题 文件上传在WEB开发中应用很广泛. 文件上传是指将本地图片.视频.音频等文件上传到服务器上,可以供其他用户浏览或下载的过程. 以下总结了常见的文件(图片)上传的方式和要点处理. 表单上传 这是传 ...

  5. 一脸懵逼学习HBase---基于HDFS实现的。(Hadoop的数据库,分布式的,大数据量的,随机的,实时的,非关系型数据库)

    1:HBase官网网址:http://hbase.apache.org/ 2:HBase表结构:建表时,不需要指定表中的字段,只需要指定若干个列族,插入数据时,列族中可以存储任意多个列(即KEY-VA ...

  6. 新的表格展示利器 Bootstrap Table Ⅰ

     1.bootstrap table简介及特征 Bootstrap Table是国人开发的一款基于 Bootstrap 的 jQuery 表格插件,通过简单的设置,就可以拥有强大的单选.多选.排序.分 ...

  7. 将Elasticsearch的快照备份到HDFS

    1.安装Elasticsearch插件repository-hdfs 下载地址:https://artifacts.elastic.co/downloads/elasticsearch-plugins ...

  8. [转] 最详尽的 JS 原型与原型链终极详解

    四. __proto__ JS 在创建对象(不论是普通对象还是函数对象)的时候,都有一个叫做__proto__ 的内置属性,用于指向创建它的构造函数的原型对象. 对象 person1 有一个 __pr ...

  9. poshytip基本使用

    js基本调用方法 $("#tips").poshytip({ content: $this.text(), alignTo: 'target', alignX: direction ...

  10. vue中methods一个方法调用另外一个方法

    转自http://blog.csdn.net/zhangjing1019/article/details/77942923 vue在同一个组件内: methods中的一个方法调用methods中的另外 ...