----------------------------------------------------------- #!/bin/bash set -e command 1 command 2 ... exit 0 ---------------------------------------------------------- Every script you write should include set -e at the top. This tells bash that it
Linux shell脚本中shift的用法说明 shift命令用于对参数的移动(左移),通常用于在不知道传入参数个数的情况下依次遍历每个参数然后进行相应处理(常见于Linux中各种程序的启动脚本). 示例1:依次读取输入的参数并打印参数个数: run.sh: #!/bin/bash while [ $# != 0 ];do echo "第一个参数为:$1,参数个数为:$#" shift done 输入如下命令运行:run.sh a b c d e f 结果显示如下: 第一个参数为