Linux Comm Expr
# Linux expr Command
[ Linux Command Manual](#)
The expr command is a manual command-line counter used to evaluate the value of expression variables under UNIX/LINUX. It is generally used for integer values but can also be used for strings.
### Syntax
expr expression
**Expression Description:**
* Separate each item with a space;
* Use a backslash before shell-specific characters;
* Enclose strings containing spaces and other special characters in quotes
### Examples
1. Calculate string length
> expr length βthis is a testβ 14
2. Extract substring
> expr substr βthis is a testβ 3 5is is
3. Find the position of the first occurrence of a character or digit string
> expr index "sarasara" a 2
4. Integer arithmetic
> expr 14 % 9 5 > expr 10 + 10 20 > expr 1000 + 900 1900 > expr 30 / 3 / 2 5 > expr 30 * 3 (When using the multiplication sign, you must use a backslash to escape its special meaning. Because the shell might misinterpret the asterisk.) 90 > expr 30 * 3 expr: Syntax error
[ Linux Command Manual](#)
YouTip