Americas

  • United States

How to Do Math in the Command Line Using Double Parentheses

Overview

In this Linux tip, Sandra Henry-Stocker—author of the Unix as a Second Language blog—shows you how to perform basic math right in the Linux command line using double parentheses syntax $(( )). Learn how to add, multiply, divide, and use multiple numbers in a single expression—all while understanding operator precedence in Bash.
📌 Commands covered:
bash
Copy
Edit
echo $((3 + 4))
echo $((10 * 5))
echo $((24 / 3))
echo $((10 * 5 + 1))
💡 Perfect for beginners and seasoned users looking to sharpen their Linux command-line skills.

Register Now