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 这样的形式定义的. 当存在空格时,可以通过双引号或单引号将其变为字符串.双引号不进行转义,单引号将内容进行转义为一 ...
随机推荐
- TabLayout和ViewPager
这里就说下tablayout+viewpager的实现方式:tablayout是android5.0推出来的一个MaterialDesign风格的控件,是专门用来实现tab栏效果的:功能强大,使用方便 ...
- spring mvc底层(DispacherServlet)的简单实现
使用过spring mvc的小伙伴都知道,mvc在使用的时候,我们只需要在controller上注解上@controller跟@requestMapping(“URL”),当我们访问对应的路径的时候, ...
- 正则化 L1 L2
机器学习中几乎都可以看到损失函数后面会添加一个额外项,常用的额外项一般有两种,一般英文称作ℓ1ℓ1-norm和ℓ2ℓ2-norm,中文称作L1正则化和L2正则化,或者L1范数和L2范数. L1正则化和 ...
- ERROR 1044 (42000): Access denied for user 'root'@'%' to database 'mysql'
原因:修改数据库账号时删除了默认的localhost root, 新建了% root 但没有赋予全部权限; 解决方法: 1.关闭数据库# mysqld stop 2.在my.cnf里加入skip-g ...
- 20165206 2017-2018-2 《Java程序设计》第9周学习总结
20165206 2017-2018-2 <Java程序设计>第9周学习总结 教材学习内容总结 URL类:URL类是java.net包中的一个重要的类,使用URL创建对象的应用程序称为客户 ...
- eclipse 中运行 Hadoop2.7.3 map reduce程序 出现错误(null) entry in command string: null chmod 0700
运行map reduce任务报错: (null) entry in command string: null chmod 0700 解决办法: 在https://download.csdn.net/d ...
- spring quartz整合实现定时器自动注解
1.web.xml中添加侦听器 <listener> <listener-class>org.springframework.web.context.ContextLoa ...
- 012-Python-paramiko和IO多路复用
1.IO 多路复用 1.监听多个socket变化 2.socket服务端 IO多路复用+socket 来实现web服务器: a.服务端优先运行 b.浏览器:http://.......com 浏览器连 ...
- Ubuntu16.04安装配置和使用ctags
Ubuntu16.04安装配置和使用ctags by ChrisZZ ctags可以用于在vim中的函数定义跳转.在ubuntu16.04下默认提供的ctags是很老很旧的ctags,快要发霉的版本( ...
- 使用jquery.more.js上滑加载更多
html: <div id="more"> <div class="single_item"> <div class=" ...