Bash - Integer

Bash Liste Des Attaques Ovh


This article is about the management of integer in bash.


See How to create a counter in Bash?


From float to int

averageCpuInt=$( printf "%.0f" "$averageCpu" )
echo $averageCpuInt;


See Bash - Arithmetic Expression


The ordinal comparison operator in Bash are:

Double Bracket operator Single Bracket Operator Example
-lt -lt [[ 8 -lt 9 ]] && echo "8 is less than 9"
-ge -ge [[ 3 -ge 3 ]] && echo "3 is greater than or equal to 3"
-gt -gt [[ 5 -gt 10 ]] || echo "5 is greater than than 10"
-le -le [[ 3 -le 8 ]] && echo "3 is less than or equal to 8"
-eq -eq [[ 5 -eq 05 ]] && echo "5 equals 05"
-ne -ne [[ 6 -ne 20 ]] && echo "6 is not equal to 20"

Discover More
Bash Liste Des Attaques Ovh
Bash - (Environment) Variable

A variable is a parameters referenced by a name. parameter A variable has: a value and zero or more attributes (such as integer, ...). Attributes are assigned using the declare builtin command....
Bash Liste Des Attaques Ovh
Bash - Conditional Expression

A predicate or boolean expression is known in Bash as a Conditional Expression. It is a command that returns an exit status of 0 or 1. The conditional expression is part of the compound expression. ...
Bash Liste Des Attaques Ovh
Bash - Declare (Variable declaration and attribute)

Declare variables and/or give them attributes. where: names: If no names are given then display the values of variables. p will display the attributes and values of each name. When -p is used,...
Bash Liste Des Attaques Ovh
Bash - If then else

if execute conditionally a block with a list of command based on the exit status of a list of command The if list. The command list) is executed (Generally there is one or more conditional command...
Bash Liste Des Attaques Ovh
Bash - Sequence

A sequence expression is a construct that creates sequence of numbers or characters. It's a brace expansion and takes the form where x and y are either: integers or single characters. A correctly-formed...
Bash Liste Des Attaques Ovh
How to create a counter in Bash?

This article shows you how to create a integer counter in Bash With the integer comparison operator and an arithmetic operation
Bash Liste Des Attaques Ovh
Sh - String Variable

String Variable, see also character string in bash. When calling a function, quote the variable otherwise bash will not see the string as atomic but as an array Sh with Bash “” The...

Share this page:
Follow us:
Task Runner