Evaluating Expressions with expr
Unix also provides expr, which you can use for evaluating expressions. (In this use, the term expressions refers to the mathematical, logical, scientific meaning of the word.) In addition to evaluating mathematical expressions, you can evaluate darn near anything else. The expr utility is often used in shell scriptsand you'll probably find the most value in expr in that contextbut it works just fine at the command line, too, as shown in Code Listing 15.3.
Code Listing 15.3. Using the expr utility, evaluating the value or the truth (or lack thereof) of expressions is straightforward.
To Evaluate with expr: