((...)): Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(7 intermediate revisions by the same user not shown)
Line 2: Line 2:


* [[Bash_Concepts#.28.28....29.29|Bash Concepts]]
* [[Bash_Concepts#.28.28....29.29|Bash Concepts]]
* [[Numbers_and_Arithmetic_in_bash|Numbers and Arithmetic in bash]]
* [[Bash_%2B%3D_and_-%3D|+= and -=]]
=Increment an Integer=
<syntaxhighlight lang='bash'>
local i=0
((i++))
</syntaxhighlight>
=Decrement an Integer=
<syntaxhighlight lang='bash'>
local i=1
((i--))
</syntaxhighlight>
=Organizatorium=
Display the value of the variable, then increment it:
<syntaxhighlight lang='bash'>
i=0
echo $((i++))
echo ${i}
</syntaxhighlight>
displays:
<syntaxhighlight lang='bash'>
0
1
</syntaxhighlight>
Increment the value of a variable, then display t:
<syntaxhighlight lang='bash'>
i=0
echo $((++i))
echo ${i}
</syntaxhighlight>
displays:
<syntaxhighlight lang='bash'>
1
1
</syntaxhighlight>

Latest revision as of 05:35, 8 May 2020

Internal

Increment an Integer

local i=0
((i++))

Decrement an Integer

local i=1
((i--))

Organizatorium

Display the value of the variable, then increment it:

i=0
echo $((i++))
echo ${i}

displays:

0
1

Increment the value of a variable, then display t:

i=0
echo $((++i))
echo ${i}

displays:

1
1