February 2001
Beginner to intermediate
448 pages
9h 2m
English
Official Description
Declares a variable as an integer.
Syntax
integer [variable[=value]]
Options
None
Oddities
integer is an alias for typeset -i.
Makes calculations faster. Shell has to convert strings to integers before performing a calculation.
Example
$ a=17 $ b=22 $ $ time for (( i=0; i<1000; i++ )) > do > (( c = $a + $b )) # Do calculations using strings > done real 0m0.26s user 0m0.26s sys 0m0.00s $ $ integer d e f # Declare variables as integers $ $ d=17 $ e=22 $ $ time for (( i=0; i<1000; i++ )) > do > (( f = e + d )) # Do calculations using integers > done real 0m0.16s # Much faster user 0m0.16s sys 0m0.00s $
Read now
Unlock full access