← All commands
Topic hub Terminal & Shell Scripting
Windows Linux Terminal & Shell Scripting Terminal

Windows set /a (arithmetic) equivalent in Linux

Evaluates mathematical expressions in scripts or at the command line.

Windows set /a (arithmetic)
Linux equivalents
Debian/Ubuntu same command
$(( expression ))
Fedora same command
$(( expression ))
Arch same command
$(( expression ))

Overview

What this command does

Evaluates mathematical expressions in scripts or at the command line.

Migration tip: Use $(( )) for integer arithmetic in bash — fast and built-in. For floating point maths use bc or python3 -c 'print(...)'.

Practical tasks

Common use cases

Perform arithmetic calculations

Evaluates mathematical expressions in scripts or at the command line.

echo $((5 + 3))

Simple arithmetic

echo $((2 ** 10))

Power: 2^10 = 1024

echo $((100 / 3))

Integer division

Ready to run

Copyable Linux commands

Review paths, device names, package names and permissions before running any command.

echo $((5 + 3))
echo $((10 * 7))
echo $((2 ** 8))
echo 'scale=2; 10/3' | bc

Walkthrough

Examples with explanations

# Windows: set /a result = 5 + 3
echo $((5 + 3))      # 8
echo $((10 * 7))     # 70
echo $((2 ** 8))     # 256

# Floating point:
echo 'scale=2; 10/3' | bc   # 3.33

Reference

Common options and variations

Command or optionUse
echo $((5 + 3))Simple arithmetic
echo $((2 ** 10))Power: 2^10 = 1024
echo $((100 / 3))Integer division
echo 'scale=4; 22/7' | bcFloat with 4 decimal places
python3 -c 'print(22/7)'Float via Python

Distro differences

Debian/Ubuntu vs Fedora vs Arch

This command is the same on Debian/Ubuntu, Fedora and Arch Linux when the relevant tool is installed.

DistributionPackage manager / baseEquivalent commandDifference to notice
Debian/Ubuntu same command $(( expression )) Same command on this distribution.
Fedora same command $(( expression )) Same command on this distribution.
Arch same command $(( expression )) Same command on this distribution.

Keep learning

Related Terminal & Shell Scripting commands