Linux Commands Reference - Complete Linux Command Guide

Comprehensive Linux command reference with 150+ commands. Search, filter by category, and view detailed usage examples.

Share
Back to commands

expr

Evaluate expressions

Syntax

expr EXPRESSION...

Common Options

ARG1 + ARG2Addition
ARG1 - ARG2Subtraction
ARG1 \* ARG2Multiplication
ARG1 / ARG2Division (integer)
ARG1 % ARG2Modulo
ARG1 = ARG2Equal (returns 1/0)
ARG1 != ARG2Not equal
length STRINGString length
substr STRING POS LENGTHSubstring
index STRING CHARSFirst position of chars

Common Examples

expr 2 + 3

Addition

expr 10 \* 5

Multiplication

expr 10 / 3

Integer division

expr 10 % 3

Modulo operation

expr length "hello"

Calculate string length

expr substr "hello" 2 3

Extract substring

x=5; expr $x + 10

Variable in expression

expr "abc" = "abc"

String comparison

Related Commands

Related Tools

More Code & Dev Tools