Arithmetic expressions are used in several situations:

* arithmetic evaluation command
* arithmetic expansion
* substring parameter expansion
* the ''let'' builtin command
* C-style for loop
* array indexing
* conditional expressions
* Assignment statements, and arguments to declaration commands of variables with the integer attribute.

Arithmetic expressions are used in several situations:

* arithmetic evaluation command
* arithmetic expansion
* substring parameter expansion
* the ''let'' builtin command
* C-style for loop
* array indexing
* conditional expressions
* Assignment statements, and arguments to declaration commands of variables with the integer attribute.

I know I can do simple arithmetic in shell scripts, like so:

#!/bin/bash
((sum = 1 + 2))
echo sum

This will output 3 on execution. My question now is, can this kind of expressions be used in crontab? For example, see this line:

03,13,23,33,43,53 * * * * ~/DoSomeStuff.sh

The minutes could be specified as x+3 with x the expression */10, which can be used in crontabs.

$(( ))

$[ ]

The arithmetic expression is evaluated and expands to the result. The output of the arithmetic expansion is guaranteed to be one word and a digit in Bash.

Please do not use the second form $[ ... ]! It's deprecated. The preferred and standardized form is $(( ... ))!

$(( ))

$[ ]

The arithmetic expression is evaluated and the resulting value replaces the whole $((...)) construct:

Please do not use the second form $[ ... ]! It's deprecated. The preferred and standardized form is $(( ... ))!

Synopsis

let

Description

The let builtin command evaluates the arithmetic expression and returns the exit codes

* 0 (TRUE) when evaluated to not 0 (arithmetic "true")
* 1 (FALSE) when evaluated to 0 (arithmetic "false")

Synopsis

let arg [arg ...]

Description

The let builtin command evaluates each supplied word from left to right as an arithmetic expression and returns an exit code according to the truth value of the rightmost expression.

* 0 (TRUE) when arg evaluated to not 0 (arithmetic "true")
* 1 (FALSE) when arg evaluated to 0 (arithmetic "false")

Synopsis

(( ))

Description

This command evaluates the arithmetic expression .

If the expression evaluates to 0 then the exit code of the expression is set to 1 (FALSE). If the expression evaluates to something else than 0, then the exit code of the expression is set to 0 (TRUE). For this return code mapping, please see this section.

PHP arithmetic operators
Today we will lear about aritmetic operators for PHP.
These are the arithmetic operators, below also a simple example, using the sum operator, to perform a simple sum of three numbers.
<!--break-->