shell script exit if any command fails
dd this to the beginning of the script:
set -e
This will cause the shell to exit immediately if a simple command exits with a nonzero exit value. A simple command is any command not part of an if, while, or until test, or part of an && or || list.
See the bash(1) man page on the "set" internal command for more details.
I personally start almost all shell scripts with "set -e". It's really annoying to have a script stubbornly continue when something fails in the middle and breaks assumptions for the rest of the script.
shell script exit if any command fails的更多相关文章
- Shell script fails: Syntax error: “(” unexpected
Shell script fails: Syntax error: “(” unexpected google 一下. http://unix.stackexchange.com/questions/ ...
- How to use ftp in a shell script
转载How to use ftp in a shell script How to use ftp in a shell script Bruce EdigerBruce Ediger's home ...
- shell script练习
执行脚本的几种方式: 1. sh a.sh 或者 bash a.sh 调用的是 /bin/bash 进程执行的,所以脚本不需要执行权限. 2. 直接使用绝对路径执行, /home/script/a ...
- shell script入门
从程序员的角度来看, Shell本身是一种用C语言编写的程序,从用户的角度来看,Shell是用户与Linux操作系统沟通的桥梁.用户既可以输入命令执行,又可以利用 Shell脚本编程,完成更加复杂的操 ...
- shell script 入门 笔记
shell script 入门 在 shell script 注意必须使用完全相同写在下面: 1. 指令的运行是从上而下.从左而右的分析与运行: 2. 指令的运行就如同第五章内提到的: 指令.选项 ...
- 第13章 学习shell script
由于博客园中dollar符号有别的意义,所以文中的dollar符号使用¥表示 第一个script [root@localhost script]# cat -n sh01.sh #!/bin/bash ...
- 学习shell script
摘要:概述.script的编写.test命令.[]判断符号.默认变量($1...).if...then条件判断式. 一.概述 [什么是shell script] 针对shell所写的脚本,将多个命令汇 ...
- Shell script之How to write
Write shell script: 1) Editor like vi or mcedi 2) Set execute permission for your script chmod perm ...
- shell script简单笔记
变量 shell script是一种脚本语言,变量的定义是通过 myName=HYB 这样的形式定义的. 当存在空格时,可以通过双引号或单引号将其变为字符串.双引号不进行转义,单引号将内容进行转义为一 ...
随机推荐
- PHP 抽象类、接口,traint详解
PHP底层实现(http://blog.jobbole.com/94475/) 一,抽象类:abstract abstract class HeHe{ public $age=18;//可以定义属性 ...
- rpm命令用法小结
rpm 是用来管理 Redhat系列的包管理工具: 通过将打包编译好的程序包文件放置在各自的位置上,就完成了安装: rpm [OPTIONS] PACHAGE_FILE 1 安装:: -i : ...
- HTML&javaSkcript&CSS&jQuery&ajax(11)
1.localStorage 没有 时间的限制数据存储, sessionStorage 针对一个session的存储,首先检查浏览器是否支持对这两个的存储, ifI(type(Storage)!==& ...
- python selenium-webdriver 生成测试报告
测试最后的一个重要的过程就是生成一份完整的测试报告,生成测试报告的主要是通过python的一个第三方模块HTMLTestRunner.py生成,但是生成的测试报告不是特别的美观,而且没有办法统计测试结 ...
- 如何用TortoiseSVN对文件进行操作
我们如何用TortoiseSVN修改文件,添加文件,删除文件,以及如何解决冲突等. 添加文件 在检出的工作副本中添加一个Readme.txt文本文件,这时候这个文本文件会显示为没有版本控制的状态,如图 ...
- mysql5.7 root用户默认密码
1. 查找密码 Mysql 5.7 在自动初始化数据库的时候,会生成root用户的默认密码. 通过 grep "temporary password" /var/log/mysql ...
- 步步为营-78-新闻展示(Ajax+Json+easyUI)
Json:JavaScript Object Notation 1.1 Json对象的接收处理 <!DOCTYPE html> <html xmlns="http://ww ...
- 如果拷贝项目出现各种找不到文件的时候,基本就是没有标记,或者文件名的问题,Could not find resource mybatis.xml,解决方法
Could not find resource mybatis.xml
- python---顺序查找,二分查找
比较熟悉了. 但要注意细节, 二分查找时,普通方法mid处理,递归时,mid处理. # coding = utf-8 def sequential_search(a_list, item): pos ...
- 关于sql和MySQL的语句执行顺序
sql和mysql执行顺序,发现内部机制是一样的.最大区别是在别名的引用上. 一.sql执行顺序 (1) from (3) join (2) on (4) where (5) group by(开始使 ...