expr Command in Linux

In the Linux system the expr command used for performing arithmetic, regular expressions and string operations. In short and technically it prints the value of Expression to standard output.

expr Command with Examples:

Open the terminal (ctrl+alt+t) application and run below commands.

1. Arithmetic Operations Using expr Command

Addition:

expr 15 + 9

expr Command addition

Subtraction:

expr 15 - 9

expr Command substraction

Multiplication:

expr 15 \* 9

expr Command multiplication

Division:

expr 100 / 10

expr Command division

2. Comparison – Check if a number is greater than another number or not.

expr 15 \> 9

expr Command Comparison

expr 15 \< 9

expr command Comparison 2

The result value 1 indicates the first number is greater than the second one. Whereas, the result value 0 indicates the first number is not greater than the second one.

Also Read:  Vara Digital Painting Application

For the complete expr command details run below commands.

man expr
expr --h
If you liked this article, please subscribe to our YouTube Channel. You can also stay connected with us on X (Twitter) and Facebook.



Leave a Reply