First page Back Continue Last page Graphics

bash Variables (pages 810 – 831)

Normally, variables are local to the current shell, but they can be exported to the environment (export built-in) so they can be globally available to all sub-shells as well.

By convention, global names are UPPER CASE while local variables use mixedCase (also known as camelCase because there's a hump in the middle) or under_scores.

Variables ought to be declared with the declare built-in even though it's not strictly necessary. I recommend that all arrays and key variables be declared, but a loop control variable (conventionally i, j, and k) need not be.