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 这样的形式定义的. 当存在空格时,可以通过双引号或单引号将其变为字符串.双引号不进行转义,单引号将内容进行转义为一 ...
随机推荐
- nginx实战(三)之静态资源web服务(跨站访问)
语法 虽然说浏览器禁止跨站访问以防(CSRF),但出于一些原因还是要进行跨站访问,服务端通过设置头信息Access-Control-Allow-Orign:xxxx,客户端收到后就会允许跨站访问了 实 ...
- Ionic 2: ReferenceError: webpackJsonp is not defined
I'm new to Ionic. I have started project with super template. But when I try to run the app in brows ...
- Socket网络编程(一)
1.什么是网络通讯?(udp.tcp.netty.mina) udp:漂流瓶,每个人都可以向大海里面扔漂流瓶,不管有没有人捡到.(不管接收方有没有,我只往指定的地址发送东西,64kb以内) tcp:电 ...
- input标签 disabled 和 readonly的区别
需求描述:今天提交代码,老大审了一下,给我指出了一个改正的地方,XXX的详细信息页面(不是修改页面) input的内容是不能改的,给我指出的时候,我立马就知道了这个该怎么改了,加个readonly不就 ...
- Python游戏编程(Pygame)
安装Pygame pip install pygame C:\Users> pip install pygame Collecting pygame Downloading https://fi ...
- Java 单字节、多字节读取文本文档中的内容
文本文档位于工程下. 鼠标右击工程,选择“new - File”,即可创建. 文本文档的格式:GBK 单字节读取 import java.io.File; import java.io.FileInp ...
- python字符编码和文件处理
一.了解字符编码的知识储备 1.文本编辑器存取文件的原理(nodepad++,python,word) 打开编辑器就打开了启动了一个进程,是在内存中的,所以,用编辑器编写的内容也都是存放于内存中的,断 ...
- bootstrap和easyui
1.easyui:自定义的样式要在原先的easyui样式之前引入,这样自定义的样式才能把原先的样式覆盖,即放置顺序为: <link rel="stylesheet" href ...
- C++ Primer 笔记——类
1.定义在类内部的函数是隐式的inline函数. 2.因为this的目的总是指向“这个”对象,所以this是一个常量指针,我们不允许改变this中保存的地址. 3.常量成员函数:允许把const关键字 ...
- Docker 快速删除所有容器
查看运行容器 docker ps 查看所有容器 docker ps -a 进入容器 其中字符串为容器ID: docker exec -it d27bd3008ad9 /bin/bash 1.停用全部运 ...