EXPR(1)
π NAME
expr β evaluate expressions β¨
π¦ SYNOPSIS
expr EXPRESSION
expr OPTION
πΈ DESCRIPTION
--helpβ display this help and exit--versionβ output version information and exit
Bestie, here's the whole vibe: expr prints the value of EXPRESSION to standard output. That's it. That's the job. π
And here's the key tea β the blank lines in the list below separate increasing precedence groups. So like, stuff higher up in the list binds looser, stuff lower down binds tighter. Lowkey important. EXPRESSION can be any of these:
π«Ά Group one β |
ARG1 | ARG2β gives you ARG1, but only if ARG1 is neither null nor0. Otherwise? You get ARG2. Simple as that.
π
Group two β &
ARG1 & ARG2β gives you ARG1 if neither argument is null or0. If either one is null or0, you get0. No cap.
π Group three β the comparisons
ARG1 < ARG2β ARG1 is less than ARG2ARG1 <= ARG2β ARG1 is less than or equal to ARG2ARG1 = ARG2β ARG1 is equal to ARG2ARG1 != ARG2β ARG1 is unequal to ARG2ARG1 >= ARG2β ARG1 is greater than or equal to ARG2ARG1 > ARG2β ARG1 is greater than ARG2
β¨ Group four β the plus/minus era
ARG1 + ARG2β arithmetic sum of ARG1 and ARG2ARG1 - ARG2β arithmetic difference of ARG1 and ARG2
π₯ Group five β the times/divide era
ARG1 * ARG2β arithmetic product of ARG1 and ARG2ARG1 / ARG2β arithmetic quotient of ARG1 divided by ARG2ARG1 % ARG2β arithmetic remainder of ARG1 divided by ARG2
π Group six β pattern matching era
STRING : REGEXPβ anchored pattern match of REGEXP in STRING. It's giving "find it, but anchored". π
π§ Group seven β the lil function words
match STRING REGEXPβ same thing asSTRING : REGEXP, just spelled outsubstr STRING POS LENGTHβ substring of STRING, and POS is counted from1(not zero, bestie, this is not an array π)index STRING CHARSβ index in STRING where any CHARS is found, or0if none of them show uplength STRINGβ length of STRING
π Group eight β the special ones
+ TOKENβ interpret TOKEN as a string, even if it is a keyword like'match'or an operator like'/'. This is your escape hatch whenexpris being too clever for its own good.( EXPRESSION )β value of EXPRESSION. Classic. Main character energy.
β οΈ Beware, bestie: many operators need to be escaped or quoted for shells. Your shell will absolutely eat your|,&,<,>,*,(,)and;if you don't wrap them up. Protect them. π«Ά
Comparisons are arithmetic if both ARGs are numbers, else lexicographical. So 10 < 9 and 10 < 9 can literally be different answers depending on whether those are numbers or plain old strings. iykyk. π
Pattern matches return the string matched between \( and \), or null. And if \( and \) are not used, they return the number of characters matched, or 0.
π EXIT STATUS
0β EXPRESSION is neither null nor0π1β EXPRESSION is null or0π2β EXPRESSION is syntactically invalid π3β an error occurred π
βοΈ AUTHOR
Written by Mike Parker, James Youngman, and Paul Eggert. Legends, honestly. π
π REPORTING BUGS
- Report bugs to:
bug-coreutils@gnu.org - GNU coreutils home page: <https://www.gnu.org/software/coreutils/>
- General help using GNU software: <https://www.gnu.org/gethelp/>
- Report any translation bugs to <https://translationproject.org/team/>
π SEE ALSO
- Full documentation <https://www.gnu.org/software/coreutils/expr>
- or available locally via:
info '(coreutils) expr invocation' - Packaged by Ubuntu (
9.10-1ubuntu2) - Copyright Β© 2026 Free Software Foundation, Inc.
- License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
okay that's the whole page π this was GNU coreutils 9.10, dated August 2026, and honestly? she ate. go forth and expr, bestie ππ¦β¨
π¦ where this page comes from
- ubuntu stonking: gnu-coreutils 9.10-1ubuntu2 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms