(1).bash命令检测Shell脚本中的语法错误

  bash -v [脚本]

[root@youxi1 ~]# vim a.sh
#/bin/bash
sum=$[$1+$2]
echoo $sum  //故意写错
[root@youxi1 ~]# bash -v a.sh
#/bin/bash
sum=$[$1+$2]
a.sh:行2: +: 语法错误: 期待操作数 (错误符号是 "+")  //报错信息
echoo $sum
a.sh:行3: echoo: 未找到命令  //报错信息

(2).bash命令查看Shell脚本详细执行过程

  bash -x [脚本]

[root@youxi1 ~]# vim a.sh
#/bin/bash
sum=$[$1+$2]
echo $sum
[root@youxi1 ~]# bash -x a.sh 5 10
+ sum=15
+ echo 15
15
[root@youxi1 ~]# vim a.sh
#/bin/bash
sum=`expr $1 + $2`
echo $sum
[root@youxi1 ~]# bash -x a.sh 5 10
++ expr 5 + 10
+ sum=15
+ echo 15
15

  

bash命令检测Shell脚本中的语法错误和查看详细执行过程的更多相关文章

  1. 利用 tee 命令调试shell脚本中的管道

    在编写shell脚本时,调试是个比较麻烦的事,特别是涉及到多层管道命令的时候,会产生多个中间结果,tee命令的作用是从标准输入中读取数据写入标准输出或文件中,利用它可以从管道中读取中间结果并写入本地临 ...

  2. shell脚本中跳转另一台主机执行命令 <<EOF

    ssh vmuser@ <<EOFmkdir /home/vmuser/xunjianrm /home/vmuser/xunjian/xj.logtouch /home/vmuser/xu ...

  3. shell脚本介绍
 shell脚本结构和执行
date命令用法
 shell脚本中的变量

  4. centos shell脚本编程2 if 判断 case判断 shell脚本中的循环 for while shell中的函数 break continue test 命令 第三十六节课

    centos  shell脚本编程2 if 判断  case判断   shell脚本中的循环  for   while   shell中的函数  break  continue  test 命令   ...

  5. shell脚本中常用命令

    1           Shell中的特殊符号 1.1           $  美元符号.用来表示变量的值.如变量NAME的值为Mike,则使用$NAME就可以得到“Mike”这个值. 1.2    ...

  6. shell脚本介绍、shell脚本结构和执行、date命令用法、shell脚本中的变量

    7月11日任务 20.1 shell脚本介绍20.2 shell脚本结构和执行20.3 date命令用法20.4 shell脚本中的变量 20.1 shell脚本介绍 1.shell脚本语言是linu ...

  7. Linux centosVMware shell脚本介绍、shell脚本结构和执行、date命令用法、shell脚本中的变量

    一. shell脚本介绍 shell是一种脚本语言 aming_linux blog.lishiming.net 可以使用逻辑判断.循环等语法 可以自定义函数 shell是系统命令的集合 shell脚 ...

  8. Shell脚本中实现切换用户并执行命令操作【转】

    第一种方法 cat test.sh #!/bin/bashsu - test <<EOFpwd;exit;EOF 执行结果图: 第二种方法 当然也可以用下面的命令来执行 复制代码代码如下: ...

  9. shell 脚本中所有循环语法

    写出 shell 脚本中所有循环语法 for 循环 : for i in $(ls);do echo item:$i done while 循环 : #!/bin/bash COUNTER=0 whi ...

随机推荐

  1. .net 异常

    ArgumentNullException 当将空引用(在 Visual Basic 中为 Nothing)传递给不接受它作为有效参数的方法时引发的异常.

  2. MySQL 快速删除大量数据

    千万级数据量 方案1. 直接使用delete 因delete执行速度与索引量成正比,若表中索引量较多,使用delete会耗费数小时甚至数天的时间   方案2. (1)创建临时表,表结构与原表结构相同 ...

  3. ReadIniTest_GetPrivateProfileString

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.R ...

  4. 第3章 Spring AOP

    3.1 Spring AOP简介 3.11什么是AOP? AOP的全称是Aspect-Oriented Programming,即面向切面编程(也称面向方面编程).它是面向对象编程(OOP)的一种补充 ...

  5. day008-python内置函数

    一.ptthon内置函数 二.内置函数详细概述 2.1  abs(x):函数返回数字的绝对值. 注意: 1)x -- 数值表达式,可以是整数,浮点数,复数. 2)如果参数是一个复数,则返回它的大小. ...

  6. (1)树莓派3B+引脚

    http://shumeipai.nxez.com/raspberry-pi-pins-version-40

  7. kuma docker-compose 环境试用

    当前官方暂时还没有使用docker-compose 运行kuma 的demo(太复杂没必要),但是做为一个本地的测试环境使用 docker-compose 运行下通用模式的kuma 还有比较有意义的, ...

  8. Vuejs发送Ajax请求

    一.概况 ①vuejs中没有内置任何ajax请求方法 ②在vue1.0版本,使用的插件 vue resource 来发送请求,支持promise ③在vue2.0版本,使用社区的一个第三方库 axio ...

  9. AtCoder Regular Contest 069 F Flags 二分,2-sat,线段树优化建图

    AtCoder Regular Contest 069 F Flags 二分,2-sat,线段树优化建图 链接 AtCoder 大意 在数轴上放上n个点,点i可能的位置有\(x_i\)或者\(y_i\ ...

  10. ffmpeg结合SDL编写播放器(二)

    我们将对帧数据做一些处理,比如将每一帧的 图像转为jpg或者bmp或者ppm等格式保存下来. 举例:在ffmpeg-2.8.8文件夹下编写test.c程序 /* test.c */ #include& ...