May 2000
Beginner
761 pages
18h 20m
English
Variables can be declared as integers with the declare -i command. If you attempt to assign any string value, bash assigns 0 to the variable. Arithmetic can be performed on variables that have been declared as integers. (If the variable has not been declared as an integer, the built-in let command allows arithmetic operations. See "The let Command" on page 394.) If you attempt to assign a floating point number, bash reports a syntax error. Numbers can also be represented in different bases such as binary, octal, and hex.
1 $ declare –i num 2 $ num=hello $ echo $num 0 3 $ num=5 + 5 bash: +: command not found 4 $ num=5+5 $ echo $num 10 5 $ num=4*6 $ echo ... |
Read now
Unlock full access