The exception is whenever let evaluates an expression that explicitly sets a variable's value.
In that case, that variable's value persists in the current shell.
Same as declare but with local bindings for functions See bash using local Synonym for declare. May be used for compatibility with ksh or other POSIX complaint shell; however, set of option available may differ. In that case, it would be advantageous to declare attributes before or on assignment in a single statement assigning value to a variable.
You may declare a variable without value to communicate that a variable may be modified from this point on or to unset a variable via assignment.
When evaluating an expression, let interprets the following mathematical operators, and performs the corresponding operation.
In the table below, operators are listed row-by-row in order of decreasing precedence.Note that declaring an associative array within a function will force local scope.To declare scope outside and use in a function omit the associative array declaration command line. Declare allows you to apply or take away attributes to variables in bash similar to how types or assigned in statically typed programming languages.-g create global variables when used in a shell function; otherwise ignored -l to convert NAMEs to lower case on assignment -n make NAME a reference to the variable named by its value -r to make NAMEs readonly -t to make NAMEs have the `trace' attribute -u to convert NAMEs to upper case on assignment -x to make NAMEs export Using ` ' instead of `-' turns off the given attribute.Variables with the integer attribute have arithmetic evaluation (see the `let' command) performed when the variable is assigned a value.(Bash does not support floating-point arithmetic.) No overflow checking is performed, so operations on very large integers may produce an unexpected result, without causing an error.Division by zero is detected, however, and causes an error.Read in 7 minutes Most programmers can get by without declare in bash. The leverage you get out of using declare and variable attributes is huge.It goes way beyond creating arrays and integer variables.It is not necessary to declare a variable for the purpose of initialization if no assignment was made prior to appearance in script.If you're used to a "standard" *NIX shell you may not be familiar with bash's array feature.