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 这样的形式定义的. 当存在空格时,可以通过双引号或单引号将其变为字符串.双引号不进行转义,单引号将内容进行转义为一 ...
随机推荐
- Android adb from work ---one
Write in front,You need to know some information first fastboot -help or adb -help (You can view the ...
- SpringBoot集成多数据源
多数据源就是连接多个数据库 1.在application.properties中配置两个数据库 spring.datasource.driverClassName=com.mysql.jdbc.Dri ...
- 【sqli-labs】Less7
Less-7: 输出文件 sql导出文件语句 select * from table_test into outfile 'test.txt' 既然名字是输出文件,那肯定是和文件有关系. 首先,确保s ...
- 【splunk】按时间统计并找到异常值
场景: 有长时间对多个端口访问的日志数据,每天对端口的访问量是稳定的.如果某一天对某个端口的访问量突然增加表示可能出现了问题.现在要通过splunk找到异常值. 思路: 统计每个端口每天的访问量.统计 ...
- centos7安装laravel
一. 安装前准备1. 安装screenyum install screen 2. 安装wgetyum install wget 3. 更新yumyum update 4. 安装额外资源库yum ins ...
- js----常用功能
切割 1. a="ddd" a.substr(0,1) 通过js找子代 document.getElementByClass("ddd").getElement ...
- php url函数
1.base64_encode 与 base64_decode base64_encode(string) 表示使用 MIME base64 对数据进行编码 base64_decode(string) ...
- JAVA代码中可使用中文类名,变量名,对象名,方法名.
java程序 兔子 public class 兔子{ //构造方法 public 兔子(){} public void 吃草(){ System.out.println("兔子在吃草&quo ...
- .net core 中的 DependencyInjection - IOC
概要:因为不知道写啥,所以随便找个东西乱说几句,嗯,就这样,就是这个目的. 1.IOC是啥呢? IOC - Inversion of Control,即控制反转的意思,这里要搞明白的就是,它是一种思想 ...
- pycharm创建python模板文件
1.新建一个项目: 2.右键单击项目名称-->选择新建-->编辑模板文件 3.编辑模板文件保存 4.新建文件测试 至此不再重复添加头部信息了