expr(1)

πŸ“¦
version 0.7.0 Β· 3 versions
, in epel 10, fedora 43, fedora 44

πŸ’– expr(1) β€” the general commands manual glow-up πŸ’–

okay bestie, welcome to expr(1), a page from the General Commands Manual that's about to become your whole personality. she prints the value of an expression to standard output, and honestly? iconic behaviour. πŸŽ€


✨ NAME ✨

expr β€” Print the value of EXPRESSION to standard output. that's it. that's the job. πŸ’…


🌸 SYNOPSIS 🌸

expr [--version] [--help] [expression]

πŸ¦‹ DESCRIPTION πŸ¦‹

Print the value of EXPRESSION to standard output. literally, that's what she does. no cap. 🫢


πŸ‘‘ OPTIONS πŸ‘‘

  • --version β€” output version information and exit. bye girl, she's leaving to tell you her version πŸ’œ
  • --help β€” display this help and exit. she's helping!! she's so helpful!! 🧚
  • [expression] β€” the expression, optional bracket situation, slay πŸ’–

🌈 EXTRA 🌈

Print the value of EXPRESSION to standard output. A blank line below separates increasing precedence groups. (iykyk β€” the groups stack up in priority, and the blank line is the little vibe check between them ✨)

EXPRESSION may be:

  • ARG1 | ARG2: ARG1 if it is neither null nor 0, otherwise ARG2
  • ARG1 & ARG2: 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
  • 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 /
  • ( EXPRESSION ): value of EXPRESSION
bestie, listen: Beware that many operators need to be escaped or quoted for shells. this is not a drill, this is the shell's whole deal 😭

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. she's got ✨range✨ fr fr πŸ”₯

Environment variables:

  • EXPR_DEBUG_TOKENS=1: dump expression's tokens
  • EXPR_DEBUG_RPN=1: dump expression represented in reverse polish notation
  • EXPR_DEBUG_SYA_STEP=1: dump each parser step
  • EXPR_DEBUG_AST=1: dump expression represented abstract syntax tree

πŸ’œ VERSION πŸ’œ

v(uutils coreutils) 0.7.0

mwah πŸ’‹ that's the whole page, and honestly? she ate. this was expr from uutils coreutils, version 0.7.0, straight out of the General Commands Manual β€” go forth and print some expressions, main character πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from
  • epel 10: rust-coreutils-devel 0.7.0-10.el10_3 Β· MIT
  • epel 10: uutils-coreutils 0.7.0-10.el10_3 Β· (MIT OR Apache-2.0) AND Unicode-DFS-2016 AND Zlib AND (0BSD OR MIT OR Apache-2.0) AND Apache-2.0 AND (Apache-2.0 OR Apache-2.0 WITH LLVM-exception) AND (Apache-2.0 OR GPL-2.0-only) AND (Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT) AND BSD-2-Clause AND (BSD-2-Clause OR Apache-2.0 OR MIT) AND BSD-3-Clause AND CC0-1.0 AND ISC AND MIT AND (MIT OR Zlib OR Apache-2.0) AND (MIT-0 OR Apache-2.0) AND Unicode-3.0 AND (Unlicense OR MIT)
  • fedora 43: rust-coreutils-devel 0.7.0-12.fc43 Β· MIT
  • fedora 43: uutils-coreutils 0.7.0-12.fc43 Β· (MIT OR Apache-2.0) AND Unicode-DFS-2016 AND Zlib AND (0BSD OR MIT OR Apache-2.0) AND Apache-2.0 AND (Apache-2.0 OR Apache-2.0 WITH LLVM-exception) AND (Apache-2.0 OR GPL-2.0-only) AND (Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT) AND BSD-2-Clause AND (BSD-2-Clause OR Apache-2.0 OR MIT) AND BSD-3-Clause AND CC0-1.0 AND ISC AND MIT AND (MIT OR Zlib OR Apache-2.0) AND (MIT-0 OR Apache-2.0) AND Unicode-3.0 AND (Unlicense OR MIT)
  • fedora 44: rust-coreutils-devel 0.7.0-4.fc44 Β· MIT
  • fedora 44: uutils-coreutils 0.7.0-4.fc44 Β· (MIT OR Apache-2.0) AND Unicode-DFS-2016 AND Zlib AND (0BSD OR MIT OR Apache-2.0) AND Apache-2.0 AND (Apache-2.0 OR Apache-2.0 WITH LLVM-exception) AND (Apache-2.0 OR GPL-2.0-only) AND (Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT) AND BSD-2-Clause AND (BSD-2-Clause OR Apache-2.0 OR MIT) AND BSD-3-Clause AND CC0-1.0 AND ISC AND MIT AND (MIT OR Zlib OR Apache-2.0) AND (MIT-0 OR Apache-2.0) AND Unicode-3.0 AND (Unlicense OR MIT)
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms