📄 expr.1
字号:
.TH EXPR 1 .SH NAMEexpr \- evaluate arguments as an expression.SH SYNOPSIS.B exprarg.B .\|.\|..SH DESCRIPTIONThe 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.I expr | expryields the first.I exprif it is neither null nor `0', otherwiseyields the second.I expr..TP.I expr & expryields the first.I exprif neither.I expris null or `0', otherwise yields `0'..TP.I expr relop exprwhere.I relop is one of< <= = != >= >,yields `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.br.IR expr " - " expr.braddition or subtraction of the arguments..TP.IR expr " * " expr.br.IR expr " / " expr.br.IR expr " % " expr.brmultiplication, division, or remainder of the arguments..TP.IR expr " : " exprThe matching operator compares the string first argumentwith the regular expression second argument;regular expression syntax is the same as that of.IR 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..PPExamples:.PPTo add 1 to the Shell variable.IR a :.IPa=\`expr $a + 1\`.PPTo find the filename part (least significant part)of the pathname stored in variable.I a,which may or may not contain `/':.IPexpr $a : \'.*/\e(\^.*\e)\' \'\^|\' $a.LPNote the quoted Shell metacharacters..SH "SEE ALSO"ed(1), sh(1), test(1).SH DIAGNOSTICS.I Exprreturns the following exit codes:.PP 0 if the expression is neither null nor `0',.br 1 if the expressionis null or `0',.br 2 for invalid expressions.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -