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 这样的形式定义的. 当存在空格时,可以通过双引号或单引号将其变为字符串.双引号不进行转义,单引号将内容进行转义为一 ...
随机推荐
- easyui合并多个单元格
$('#table-v2').datagrid({ url: './data/am/data1_table.json', pagination: true, //显示分页 fit: true, //d ...
- ajax之阴影效果实现(对象函数方法)
shadow.js文件内容jQuery.fn.shadow = function () { //获取到每个已封装的元素 //this表示jQuery对象 this.each(function () { ...
- 常见的爬虫分析库(1)-Python3中Urllib库基本使用
原文来自:https://www.cnblogs.com/0bug/p/8893677.html 什么是Urllib? Python内置的HTTP请求库 urllib.request ...
- javascript 面向对象-面试题实例
/ 从设计到模式 // 设计模式简介 // 设计 // 模式 // 分开 // 从设计到模式 // 23种设计模式 // 创建型 // 工厂模式(工厂方法模式,抽象工厂模式,建造者模式) // 单例模 ...
- Linux-server-sshd
Linux-server-sshd 1:安装 OpenSSH 服务需要4 个软件包 openssh-5.3p1-114.el6_7.x86_64:包含OpenSSH 服务器及客户端需要的核心文件 op ...
- 一 time与datetime模块
时间戳(timestamp):通常来说,时间戳表示的是从1970年1月1日00:00:00开始按秒计算的偏移量.我们运行“type(time.time())”,返回的是float类型. 格式化的时间字 ...
- win10ssh连接ubuntu服务器并本地绘图
update @ 2018-11-07 00:36:38 用xrdp+tigervnc等的组合,可以使用原生unity桌面.具体教程见ubuntu日常使用指南 工具准备 win10上: xshell, ...
- python--自己实现的单链表常用功能
最近一个月,就耗在这上面吧. 很有收获的. # coding = utf-8 # 单向链表 class Node: def __init__(self, new_data): self.data = ...
- java.net.UnknownHostException: master
1:如果你报这个错误,第一反应应该是本地的host文件没有配置服务器名称和对应的ip地址,这个反应就对了.贴一下错误和解决方法: java.net.UnknownHostException: mast ...
- T4模版自动生成MSSQL实体类
在Model层建立ModelAuto.ttinclude文件 <#@ assembly name="System.Core"#> <#@ assembly nam ...