← All commands
Topic hub Terminal & Shell Scripting
Windows Linux Terminal & Shell Scripting Expanded guide 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

On Windows, "set /a (arithmetic)" is used to perform arithmetic calculations. On Linux, the closest practical mapping shown here is "$(( expression ))". Evaluates mathematical expressions in scripts or at the command line. This reference is grouped under Terminal & Shell Scripting → Terminal.

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

Windows → Linux context

What changes when you use this on Linux?

Equivalent task, different tool

Windows set /a (arithmetic) maps to $(( expression )) for this task. Treat this as a workflow mapping rather than a character-for-character syntax translation.

Portable across the compared distros

The Debian/Ubuntu, Fedora and Arch rows use the same command in this mapping. Package availability or defaults can still vary, so check the installed tool version when an option behaves differently.

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

Debian/Ubuntu, Fedora and Arch all use "$(( expression ))" for this mapping. The command syntax shown here is portable across the three rows, although installed versions and system defaults can still vary.

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