| Click Link Network Administrator | Network administrator admin linux administraton - network security internet security free administration guide network security linux administrator | Click Link Linux - Internet Security | Linux security optimizing linux internet security free ebook security tips and guide linux network security administrator e-book optimization | Click Link Linux Network Security Administrator | Linux security optimizing linux internet security free ebook security tips and guide linux network security administrator e-book optimization | Click Link Linux Documentation Project - Add your work | LDP autor guide - Free linux manual's download help ? You also can add you work !!!! | Click Link Free Gnu Video Software | Videolan guide videolan user manual free video software vls vlc - videolanlan video free gnu video software |
Arithmetic expansion provides a powerful tool for performing (integer) arithmetic operations in scripts. Translating a string into a numerical expression is relatively straightforward using backticks, double parentheses, or let.
z=`expr $z + 3` # The 'expr' command performs the expansion. |
The use of backticks in arithmetic expansion has been superseded by double parentheses -- ((...)) and $((...)) -- and also by the very convenient let construction.
z=$(($z+3))
z=$((z+3)) # Also correct.
# Within double parentheses,
#+ parameter dereferencing
#+ is optional.
# $((EXPRESSION)) is arithmetic expansion. # Not to be confused with
#+ command substitution.
# You may also use operations within double parentheses without assignment.
n=0
echo "n = $n" # n = 0
(( n += 1 )) # Increment.
# (( $n += 1 )) is incorrect!
echo "n = $n" # n = 1
let z=z+3
let "z += 3" # Quotes permit the use of spaces in variable assignment.
# The 'let' operator actually performs arithmetic evaluation,
#+ rather than expansion. |
Examples of arithmetic expansion in scripts: