EXPR(1)

โœจ EXPR(1) โ€” the expr glow-up โœจ

okay bestie, sit down, we're learning expr ๐Ÿ’… it lives in User Commands land and it literally just... evaluates expressions. that's the whole vibe.


๐ŸŒธ NAME ๐ŸŒธ

expr โ€” evaluate expressions ๐Ÿงฎโœจ


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

expr EXPRESSION
expr OPTION

๐Ÿ’– DESCRIPTION ๐Ÿ’–

  • --help โ€” display this help and exit ๐Ÿฅฐ
  • --version โ€” output version information and exit ๐Ÿ‘‘

then it prints the value of EXPRESSION to standard output. the blank line below separates the increasing-precedence groups (so like, the stuff lower down binds tighter, iykyk). EXPRESSION may be:

  • ARG1 | ARG2 โ€” gives you ARG1 if it's neither null nor 0, otherwise ARG2 ๐Ÿฆ‹
  • ARG1 & ARG2 โ€” gives you ARG1 if neither argument is null or 0, otherwise 0 ๐Ÿ’€
  • ARG1 < ARG2 โ€” ARG1 is less than ARG2
  • ARG1 <= ARG2 โ€” ARG1 is less than or equal to ARG2
  • ARG1 = ARG2 โ€” ARG1 is equal to ARG2
  • ARG1 != ARG2 โ€” ARG1 is unequal to ARG2
  • ARG1 >= ARG2 โ€” ARG1 is greater than or equal to ARG2
  • ARG1 > ARG2 โ€” ARG1 is greater than ARG2
  • ARG1 + ARG2 โ€” arithmetic sum of ARG1 and ARG2 โž•
  • ARG1 - ARG2 โ€” arithmetic difference of ARG1 and ARG2 โž–
  • ARG1 * ARG2 โ€” arithmetic product of ARG1 and ARG2 โœ–๏ธ
  • ARG1 / ARG2 โ€” arithmetic quotient of ARG1 divided by ARG2 โž—
  • ARG1 % ARG2 โ€” arithmetic remainder of ARG1 divided by ARG2 ๐Ÿ“
  • STRING : REGEXP โ€” anchored pattern match of REGEXP in STRING ๐Ÿ”
  • match STRING REGEXP โ€” same as STRING : REGEXP fr fr
  • substr STRING POS LENGTH โ€” substring of STRING, POS counted from 1 โœ‚๏ธ
  • index STRING CHARS โ€” index in STRING where any CHARS is found, or 0 ๐Ÿงญ
  • length STRING โ€” length of STRING ๐Ÿ“
  • + TOKEN โ€” interpret TOKEN as a string, even if it is a keyword like 'match' or an operator like '/' ๐Ÿ™ˆ (this one is the sneaky icon tbh)
  • ( EXPRESSION ) โ€” value of EXPRESSION ๐Ÿซถ
โš ๏ธ bestie beware: many operators need to be escaped or quoted for shells. no cap. if you forget, your shell will eat your operators and you'll be sad ๐Ÿ˜ญ

comparisons are arithmetic if both ARGs are numbers, else lexicographical. pattern matches return the string matched between \( and \) or null; if \( and \) are not used, they return the number of characters matched or 0. ๐Ÿ’…

exit status is 0 if EXPRESSION is neither null nor 0, 1 if EXPRESSION is null or 0, 2 if EXPRESSION is syntactically invalid, and 3 if an error occurred. so basically 0 = slay, 1 = falsy vibes, 2 = syntax said no, 3 = something actually broke ๐ŸŒˆ


๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Written by Mike Parker, James Youngman, and Paul Eggert. legends, honestly ๐Ÿซกโœจ


๐Ÿ› REPORTING BUGS ๐Ÿ›

Report bugs to: <bug-coreutils@gnu.org>. Report any translation bugs to: <https://translationproject.org/team/>. GNU coreutils home page: <https://www.gnu.org/software/coreutils/> General help using GNU software: <https://www.gnu.org/gethelp/>

like pls tell them, they wanna know ๐Ÿ’œ


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.

๐Ÿšจ there is NO WARRANTY bestie. none. zero. read it again, to the extent permitted by law.

๐ŸŒˆ SEE ALSO ๐ŸŒˆ

Full documentation <https://www.gnu.org/software/coreutils/expr> or available locally via: info '(coreutils) expr invocation'


and that's the whole page, main character energy only โœจ this was GNU coreutils 9.12, dated September 2026 โ€” go forth and expr responsibly, bestie ๐Ÿ’–๐ŸŽ€๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from