summaryrefslogtreecommitdiff
path: root/static/v10/man1/expr.1
diff options
context:
space:
mode:
Diffstat (limited to 'static/v10/man1/expr.1')
-rw-r--r--static/v10/man1/expr.1112
1 files changed, 112 insertions, 0 deletions
diff --git a/static/v10/man1/expr.1 b/static/v10/man1/expr.1
new file mode 100644
index 00000000..3bc6fe3b
--- /dev/null
+++ b/static/v10/man1/expr.1
@@ -0,0 +1,112 @@
+.TH EXPR 1
+.CT 1 shell
+.SH NAME
+expr \- integer and string-match expression evaluator for shell scripts
+.SH SYNOPSIS
+.B expr
+.I arg ...
+.SH DESCRIPTION
+The arguments are taken as an expression.
+After evaluation, the result is written on the standard output.
+Each token of the expression is a separate argument.
+.PP
+The operators and keywords are listed below
+in order of increasing precedence,
+with equal precedence operators grouped.
+.TP \w'\f5(\fI\ expr\ \f5)\ 'u
+.IB expr1 " | " expr2
+Value is the value of
+.I expr1
+if that is neither empty nor 0,
+otherwise the value of
+.IR expr2.
+.TP
+.IB expr1 " & " expr2
+Value is the value of
+.I expr1
+if neither
+.I expr1
+nor
+.I expr2
+is empty or 0, otherwise 0.
+.TP
+.I expr1 relop expr2
+.I Relop
+is one of
+.L "< <= = != >= >" .
+Value is 1
+if the indicated comparison is true, 0
+if false.
+The comparison is numeric if both
+.I expr
+are integers, otherwise lexicographic.
+.TP
+.IB expr1 " + " expr2
+.br
+.ns
+.TP
+.IB expr1 " - " expr2
+.br
+Value is the sum or difference of the (integer) values of
+.I expr1
+and
+.I expr2.
+.TP
+.IB expr1 " * " expr2
+.br
+.ns
+.TP
+.IB expr1 " / " expr2
+.br
+.ns
+.TP
+.IB expr1 " % " expr2
+.br
+Value is the product, quotient, or remainder of the (integer)
+values of
+.I expr1
+and
+.I expr2.
+.TP
+.IB expr " : " regexp
+Match the string value of
+.I expr
+with the regular expression
+.IR regexp ;
+regular expression syntax is the same as in
+.IR ed (1),
+but matches are anchored at the left.
+On success a subexpression
+.BR \e(\| ... \|\e) ,
+if present in
+.I regexp,
+picks out a return value from the matched string.
+Otherwise,
+the matching operator yields the number of characters matched
+(0 on failure).
+.TP
+.BI ( " expr " )
+Parentheses for grouping.
+.TP
+.I arg
+Value is the string
+.I arg.
+.PP
+.SH EXAMPLES
+.TP
+.L
+a=`expr $a + 1`
+Add 1 to shell variable
+.IR a .
+.TP
+.L
+expr $a : '.*/\e(.*\e)' '|' $a
+Same as
+.LR "basename $a" .
+.SH "SEE ALSO"
+.IR sh (1),
+.IR test (1)
+.SH DIAGNOSTICS
+.I Expr
+returns exit code 0 if the expression is neither null nor 0,
+1 if the expression is null or 0, 2 for invalid expressions.