This reference page shows usage of Bash shell options, variables, string manipulation, arrays, functions, sub-shells and traps.

Shell Options

# exit on any errors
set -e
set -o errexit
set -o errtrace
# don't overwrite on shell redirect (>)
set -C
set -o noclobber
# vars must be created/declared first
set -o nounset
# tracing
set -x
set -o xtrace

Variables & Arrays

# declare variables

a_var="some value"
declare a_var

# Assign from output of (command substitution)
thiscmd=$( readlink -f $0 )
thisdir=$( dirname $( readlink -f $0 ) )

# create a constant
declare -r PI=3.14159265358979
declare -r DecimalConstant=31373

See Also