GNU Info

Info Node: (sh-utils.info)Examples of expr

(sh-utils.info)Examples of expr


Prev: Relations for expr Up: expr invocation
Enter node , (file) or (file)node

Examples of using `expr'
------------------------

   Here are a few examples, including quoting for shell metacharacters.

   To add 1 to the shell variable `foo', in Bourne-compatible shells:
     foo=`expr $foo + 1`

   To print the non-directory part of the file name stored in `$fname',
which need not contain a `/'.
     expr $fname : '.*/\(^.*\)' '^|' $fname

   An example showing that `\+' is an operator:
     expr aaa : 'a\+'
     => 3

     expr abc : 'a\(.\)c'
     => b
     expr index abcdef cz
     => 3
     expr index index a
     error--> expr: syntax error
     expr index quote index a
     => 0


automatically generated by info2www version 1.2.2.9