简单示例
// 通过shell脚本打开某个文件夹cd ~touch test.shvim test.sh// 添加以下内容#!bin/bashcd desktop/studyopen ./chmod 775 ./test.sh./test.sh
前端部署nginx
set -ex
set -e // 这个参数的含义是,当命令发生错误的时候,停止脚本的执行#!/bin/bashecho 1 && rm non-existent-file && echo 2// 等同#!/bin/bashset -eecho 1rm non-existent-file # which will failecho 2set -x // -x 参数的作用,是把将要运行的命令用一个 + 标记之后显示出来#!/bin/bashset -execho 1rm non-existent-file # which will failecho 2// 输出+ echo 11+ rm non-existent-filerm: non-existent-file: No such file or directory
