"expr" Command

Learn all about expr command

HOME

expr - evaluate expressions

root:~# man expr
          
In Examples,
Note-1 Beware that many operators need to be escaped or quoted for shells. Comparisons are arithmetic if both ARGs are numbers, else lexicographical. Pattern matches return the string matched between \( and \) or null; if \( and \) are not used, they return the number of characters matched or 0.
Note-2 Exit status is 0 if EXPRESSION is neither null nor 0, 1 if EXPRESSION is null or 0, 2 if EXPRESSION is syntactically invalid, and 3 if an error occurred.
Note-3 Operator has been separated by space otherwise treated as one expression as shown in Example-1.1