[Chapter 49] 49.6 Quick Arithmetic with expr
Author: Jerry Peek, Tim O'Reilly & Mike Loukides
Date: 1998-08-04T21:56:41Z

#

| Chapter 49 Working with Numbers |

## 49.6 Quick Arithmetic with expr

The expr command does arithmetic. It's not just for incrementing a variable in a Bourne shell loop. It's handy for quick integer math on the command line. For instance, if wc tells me a file has 2545 lines and I want to know how many 66-line pages that is:

>     $ expr 2545 / 66
>     38

It's 38 pages - actually, 39, because expr rounds down.

Article 45.28 has a complete list of expr math operators.

- JP

49.5 Base Conversion Using cvtbase |  | 49.7 Total a Column with addup