1EXPR(1)                          User Commands                         EXPR(1)
2
3
4

NAME

6       expr - evaluate expressions
7

SYNOPSIS

9       expr EXPRESSION
10       expr OPTION
11

DESCRIPTION

13       --help display this help and exit
14
15       --version
16              output version information and exit
17
18       Print  the  value of EXPRESSION to standard output.  A blank line below
19       separates increasing precedence groups.  EXPRESSION may be:
20
21       ARG1 | ARG2
22              ARG1 if it is neither null nor 0, otherwise ARG2
23
24       ARG1 & ARG2
25              ARG1 if neither argument is null or 0, otherwise 0
26
27       ARG1 < ARG2
28              ARG1 is less than ARG2
29
30       ARG1 <= ARG2
31              ARG1 is less than or equal to ARG2
32
33       ARG1 = ARG2
34              ARG1 is equal to ARG2
35
36       ARG1 != ARG2
37              ARG1 is unequal to ARG2
38
39       ARG1 >= ARG2
40              ARG1 is greater than or equal to ARG2
41
42       ARG1 > ARG2
43              ARG1 is greater than ARG2
44
45       ARG1 + ARG2
46              arithmetic sum of ARG1 and ARG2
47
48       ARG1 - ARG2
49              arithmetic difference of ARG1 and ARG2
50
51       ARG1 * ARG2
52              arithmetic product of ARG1 and ARG2
53
54       ARG1 / ARG2
55              arithmetic quotient of ARG1 divided by ARG2
56
57       ARG1 % ARG2
58              arithmetic remainder of ARG1 divided by ARG2
59
60       STRING : REGEXP
61              anchored pattern match of REGEXP in STRING
62
63       match STRING REGEXP
64              same as STRING : REGEXP
65
66       substr STRING POS LENGTH
67              substring of STRING, POS counted from 1
68
69       index STRING CHARS
70              index in STRING where any CHARS is found, or 0
71
72       length STRING
73              length of STRING
74
75       + TOKEN
76              interpret TOKEN as a string, even if it is a
77
78              keyword like 'match' or an operator like '/'
79
80       ( EXPRESSION )
81              value of EXPRESSION
82
83       Beware that many operators need to be escaped  or  quoted  for  shells.
84       Comparisons are arithmetic if both ARGs are numbers, else lexicographi‐
85       cal.  Pattern matches return the string matched between \(  and  \)  or
86       null;  if  \( and \) are not used, they return the number of characters
87       matched or 0.
88
89       Exit status is 0 if EXPRESSION is neither null nor 0, 1  if  EXPRESSION
90       is null or 0, 2 if EXPRESSION is syntactically invalid, and 3 if an er‐
91       ror occurred.
92

AUTHOR

94       Written by Mike Parker, James Youngman, and Paul Eggert.
95

REPORTING BUGS

97       GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
98       Report any translation bugs to <https://translationproject.org/team/>
99
101       Copyright © 2020 Free Software Foundation, Inc.   License  GPLv3+:  GNU
102       GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
103       This  is  free  software:  you  are free to change and redistribute it.
104       There is NO WARRANTY, to the extent permitted by law.
105

SEE ALSO

107       Full documentation <https://www.gnu.org/software/coreutils/expr>
108       or available locally via: info '(coreutils) expr invocation'
109
110
111
112GNU coreutils 8.32                 July 2021                           EXPR(1)
Impressum