home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 49.5 Base Conversion Using cvtbase Chapter 49
Working with Numbers
Next: 49.7 Total a Column with addup
 

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


Previous: 49.5 Base Conversion Using cvtbase UNIX Power Tools Next: 49.7 Total a Column with addup
49.5 Base Conversion Using cvtbase Book Index 49.7 Total a Column with addup

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System