expr.1
来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· 1 代码 · 共 101 行
1
101 行
.\" SCCSID: @(#)expr.1 8.1 9/11/90.\" SCCSID: @(#)expr.1 8.1 9/11/90.TH expr 1 .SH Nameexpr \- evaluate expressions.SH Syntax.B expr\fIarg\fR....SH Description.NXR "expr command".NXR "expression" "taking arguments as"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..PPThe operators and keywords are listed below.The list is in order of increasing precedence,with equal precedence operators grouped..TP 20.IR expr " | " exprYields the first.I exprif it is neither null nor 0. Otherwiseyields the second.I expr..TP.IR expr " & " exprYields the first.I exprif neither.I expris null or 0. Otherwise yields 0..TP.I expr relop exprThe.I relopis one of< <= = != >= > andyields 1 if the indicated comparison is true, '0' if false.The comparison is numeric if both.I exprare integers, otherwise lexicographic..TP.IR expr " + " expr.RS 5.IR expr " - " expr.RE.RS 20Yields addition or subtraction of the arguments..RE.TP 20.IR expr " * " expr.RS 5.IR expr " / " expr.br.IR expr " % " expr.RE.RS 20Yields multiplication, division, or remainder of the arguments..RE.TP 20.IR expr " : " exprThe matching operator compares the string first argumentwith the regular expression second argument;regular expression syntax is the same as that of.MS ed 1 .The\fB\\(\|.\|.\|.\|\\)\fPpattern symbols can be used to select a portion of thefirst argument.Otherwise,the matching operator yields the number of characters matched('0' on failure)..TP.RI ( " expr " )parentheses for grouping..SH Examples.NXR "expr command" "examples"The first example adds 1 to the Shell variable \fIa\fP\^:.EXa=\`expr $a + 1\`.EEThe second example finds the file name part (least significant part)of the pathname stored in variable \fIa,.EXexpr $a : \'.*/\e(\^.*\e)\' \'\^|\' $a.EENote the quoted Shell metacharacters..SH DiagnosticsThe .PN exprcommand returns the following exit codes:.IP 0 5The expression is neither null nor '0'..IP 1The expression is null or '0'..IP 2The expression is invalid..SH See Alsoed(1), sh(1), test(1)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?