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
91       error occurred.
92
93       GNU  coreutils  online  help:  <http://www.gnu.org/software/coreutils/>
94       Report expr translation bugs to <http://translationproject.org/team/>
95

AUTHOR

97       Written by Mike Parker, James Youngman, and Paul Eggert.
98
100       Copyright  ©  2013  Free Software Foundation, Inc.  License GPLv3+: GNU
101       GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
102       This is free software: you are free  to  change  and  redistribute  it.
103       There is NO WARRANTY, to the extent permitted by law.
104

SEE ALSO

106       The  full documentation for expr is maintained as a Texinfo manual.  If
107       the info and expr programs are properly installed  at  your  site,  the
108       command
109
110              info coreutils 'expr invocation'
111
112       should give you access to the complete manual.
113
114
115
116GNU coreutils 8.22               October 2018                          EXPR(1)
Impressum