Bash variables

From wikinotes
Revision as of 16:02, 17 January 2021 by Will (talk | contribs) (→‎Assignment)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Assignment

var="var"
FOO=${VARIABLE:=default}

test variable

test -z $var && echo "variable does not exist, or has no value"
test -n $var && echo "variable exists and has a nonzero value"

There are many more options. See man test.