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