Performing Arithmetic Operations in Shell Scripts

In the last chapter, you learned about debugging, the here operator, interactive shell scripts for taking input from the keyboard, and file handling.

In this chapter, we will cover the following arithmetic operations topics:

  • Addition
  • Subtraction
  • Multiplication
  • Division
  • Modulus

We can perform arithmetic operations in various ways, such as using declare, let, expr, and arithmetic expressions. You will also learn about representing numbers in different bases, such as binary, octal, and hex.

Get Learning Linux Shell Scripting - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.