Linux and Unix expr command
Evaluate arguments as an expression.
|expr1 | expr2||results in the value expr1 if expr1 is true; otherwise it results in the value of expr2.|
|expr1 &||results in the value of expr1 if both expressions are true; otherwise it results in 0|
|If both expr1 and expr2 are numeric, expr compares them as numbers; otherwise it compares them as strings. If the comparison is true, the expression results in 1; otherwise it results in 0.|
|performs addition or subtraction on the two expressions. If either expression is not a number, expr exits with an error.|
|performs multiplication, division, or modulus on the two expressions. If either expression is not a number, expr exits with an error. Note that the multiplication symbol (*) is expanded under the KornShell unless you specify it with a leading backslash (\\*), or enclosed in single quotes ('*') or double quotes ("*"). Under command.com you cannot use the backslash to prevent expansion|
|expr1 : re
match expr1 re
|matches the regular expression re against expr1 treated as a string. The regular expression is the same as that accepted by ed, except that the match is always anchored, that is, there is an implied leading ^; therefore expr does not consider ^ to be a metacharacter. If the regular expression contains \(...\) and it matches at least part of expr1, then expr results in only that part; if there is no match, expr results in 0. If the regular expression doesn't contain this construct, then the result is the number of characters matched. The function match performs the same operation as the colon operator.|
|substr expr1 expr2 expr3||results in the substring of expr1 starting at character position expr2 (origin 1) for the length of expr3 characters.|
|index expr1 expr2||searches for any of the characters in expr2 in expr1 and returns the first character position (origin 1) at which it finds such a character, or 0 if no such characters are found.|
|length expr1||returns the length of expr1 in characters.|
expr "$VAR" : '.*'
Return the number of characters in $VAR.