www.delorie.com/gnu/docs/textutils/coreutils_102.html   search  
 
Buy GNU books!


GNU Core-utils

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16.4 expr: Evaluate expressions

expr evaluates an expression and writes the result on standard output. Each token of the expression must be a separate argument.

Operands are either numbers or strings. expr converts anything appearing in an operand position to an integer or a string depending on the operation being applied to it.

Strings are not quoted for expr itself, though you may need to quote them to protect characters with special meaning to the shell, e.g., spaces.

Operators may be given as infix symbols or prefix keywords. Parentheses may be used for grouping in the usual manner (you must quote parentheses to avoid the shell evaluating them, however).

Exit status:

 
0 if the expression is neither null nor 0,
1 if the expression is null or 0,
2 for invalid expressions.

16.4.1 String expressions  + : match substr index length
16.4.2 Numeric expressions  + - * / %
16.4.3 Relations for expr  | & < <= = == != >= >
16.4.4 Examples of using expr  Examples.


  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003