Annotation of cci/usr/src/man/man1/expr.1, revision 1.1.1.1

1.1       root        1: .TH EXPR 1  "18 January 1983"
                      2: .SH NAME
                      3: expr \- evaluate arguments as an expression
                      4: .SH SYNOPSIS
                      5: .B expr
                      6: arg
                      7: .B .\|.\|.
                      8: .SH DESCRIPTION
                      9: The arguments are taken as an expression.
                     10: After evaluation, the result is written on the standard output.
                     11: Each token of the expression is a separate argument.
                     12: .PP
                     13: The operators and keywords are listed below.
                     14: The list is in order of increasing precedence,
                     15: with equal precedence operators grouped.
                     16: .TP
                     17: .I expr | expr
                     18: yields the first
                     19: .I expr
                     20: if it is neither null nor `0', otherwise
                     21: yields the second
                     22: .I expr.
                     23: .TP
                     24: .I expr & expr
                     25: yields the first
                     26: .I expr
                     27: if neither
                     28: .I expr
                     29: is null or `0', otherwise yields `0'.
                     30: .TP
                     31: .I expr relop expr
                     32: where
                     33: .I relop is one of
                     34: < <= = != >= >,
                     35: yields `1' if the indicated comparison is true, `0' if false.
                     36: The comparison is numeric if both
                     37: .I expr
                     38: are integers, otherwise lexicographic.
                     39: .TP
                     40: .IR expr " + " expr
                     41: .br
                     42: .ns
                     43: .TP
                     44: .IR expr " \- " expr
                     45: .br
                     46: addition or subtraction of the arguments.
                     47: .TP
                     48: .IR expr " * " expr
                     49: .br
                     50: .ns
                     51: .TP
                     52: .IR expr " / " expr
                     53: .br
                     54: .ns
                     55: .TP
                     56: .IR expr " % " expr
                     57: .br
                     58: multiplication, division, or remainder of the arguments.
                     59: .TP
                     60: .IR expr " : " expr
                     61: The matching operator compares the string first argument
                     62: with the regular expression second argument;
                     63: regular expression syntax is the same as that of
                     64: .IR ed (1).
                     65: The
                     66: \fB\\(\|.\|.\|.\|\\)\fP
                     67: pattern symbols can be used to select a portion of the
                     68: first argument.
                     69: Otherwise,
                     70: the matching operator yields the number of characters matched
                     71: (`0' on failure).
                     72: .TP
                     73: .RI ( " expr " )
                     74: parentheses for grouping.
                     75: .PP
                     76: Examples:
                     77: .PP
                     78: To add 1 to the Shell variable
                     79: .IR a :
                     80: .IP
                     81: a=\`expr $a + 1\`
                     82: .PP
                     83: To find the filename part (least significant part)
                     84: of the pathname stored in variable
                     85: .I a,
                     86: which may or may not contain `/':
                     87: .IP
                     88: expr $a : \'.*/\e(\^.*\e)\' \'\^|\' $a
                     89: .LP
                     90: Note the quoted Shell metacharacters.
                     91: .SH "SEE ALSO"
                     92: sh(1), test(1)
                     93: .SH DIAGNOSTICS
                     94: .I Expr
                     95: returns the following exit codes:
                     96: .PP
                     97:        0       if the expression is neither null nor `0',
                     98: .br
                     99:        1       if the expression
                    100: is null or `0',
                    101: .br
                    102:        2       for invalid expressions.

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.