「Shell」- 快速入门及简单示例

  CREATED BY JENKINSBOT

# 显示当前Shell正在执行的命令

-「How to echo shell commands as they are executed
展开变量并在行前打印加号:set -xset -o xtrace
在打印之前,并不展开变量:set -vset -o verbose

# 当遇到错误时立即退出

-「bash: Trap error and exit
在执行脚本时,遇到错误立即退出:set -e

# 取消函数定义

-「How do I unset or get rid of a bash function?
执行命令:unset -f function_name

# PowerShell Gallery

Welcome to the PowerShell Gallery

How to add arithmetic variables in a script

How to add arithmetic variables in a script

以下是几种不同的写法,以及各自的兼容性:

# portable but slow
a=`expr "$a" + "$num"`

# POSIX and portable except to the Bourne shell and earlier versions of the Almquist shell
a=$(($a+$num))

# require ksh, bash or zsh
((a=a+num))

let a=a+num

((a+=num))