table.
Operator Function Example
${foo:-bar} If $foo exists and is not null, return $foo. If it doesn't exist or is null, return bar. export ... =""
echo ${foo:-one}
one
echo $foo
${foo:=bar} If $foo exists and is not null, return $foo. If it doesn't exist or is null, set $foo to bar and ... echo ${foo:=one}
one
echo $foo
one
${foo:+bar} If $foo exists and is not null, return bar. If it doesn't exist, or is null, return a null. exp... "
echo ${foo:+bar}
bar
${foo:?"error message"} If $foo exists and is not null, return its value. If it doesn't exist or is null, print the error mess
filter.
E_NOARGS=65
E_NOTFOUND=66
E_NOTGZIP=67
if [ $# -eq 0 ] # same effect as: if [ -z "$1" ]
# $1 can exist, but be empty: zmore ... status of script (error code).
fi
filename=$1
if [ ! -f "$filename" ] # Quoting $filename allows... Error message to stderr.
exit $E_NOTFOUND
fi
if [ ${filename##*.} != "gz" ]
# Using bracket in va... # Uses the 'more' filter.
# May substitute 'less' if desired.
exit $? # Script returns exit status