((...)): Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 3: | Line 3: | ||
* [[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]] | * [[Numbers_and_Arithmetic_in_bash|Numbers and Arithmetic in bash]] | ||
=Increment an Integer= | =Increment an Integer= | ||
Line 13: | Line 10: | ||
((i++)) | ((i++)) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=Decrement an Integer= | =Decrement an Integer= | ||
<syntaxhighlight lang='bash'> | <syntaxhighlight lang='bash'> | ||
local i=1 | local i=1 | ||
((i--)) | ((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> | </syntaxhighlight> |
Revision as of 01:43, 14 March 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