MPE/iX Shell and Utilities Reference Manual, Vol 1

expr(1) MPE/iX Shell and Utilities expr(1)
expr1 expr2
expr1 / expr2
expr1 % expr2
performs multiplication, division, or modulus on the two expressions. If either
expression is not a number, expr exits with an error.
expr1 : re
match expr1 re
matches the regular expression re against expr1 treated as a string. The regular
expression is the same as that accepted by ed, except that the match is always
anchored, that is, there is an implied leading ˆ; therefore expr does not consider ˆ
to be a metacharacter. If the regular expression contains \(...\) and it matches at
least part of expr1, then expr results in only that part; if there is no match, expr
results in 0. If the regular expression doesn’t contain this construct, then the result is
the number of characters matched. The function match performs the same opera-
tion as the colon operator.
substr expr1 expr2 expr3
results in the substring of expr1 starting at position expr2 (origin 1) for the length of
expr3.
index expr1 expr2
searches for any of the characters in expr2 in expr1 and results in the offset of any
such character (origin 1), or 0 if no such characters are found.
length expr1
results in the length of expr1.
( expr ) groups expressions.
EXAMPLES
fname=src/fn_abs.c
expr $fname : ’.*_\(.*\)\.c’
returns abs.
a=`expr $a + 1`
adds one to the value of the shell variable a.
1-220 Commands and Utilities