MAN page from PLD akanga-1.0.7-2.i386.rpm
AKANGAEXPR
Section: User Commands (1)
Updated: 7 August 1999
Index NAME
expr - evaluate expressions in akanga
SYNOPSIS
expr[
-e][
expr...
] DESCRIPTION
The
exprcommand evaluates arithmetic expressions in
akanga(1),similiar to the external
expr(1).Each given expression is evaluated and, if the
-eoption is given, the result of it is printed.The value of the last expression defines the exit code: If it'svalue is 0 the exit code is 1 and 0 otherwise.
OPERANDS
expraccepts numbers and strings as operands, operands are coerced to thedata types an operator expects.Numbers may begin with
0x of a
0 in which case the numberis interpreted as hexadecimal or octal number.Otherwise
exprexpects numbers to of the form
base#number.
Strings are usually quoted with double quotes ``"'' but you mayuse single quotes ``''' as well. Within a quoted stringexprrecognizes the following escape sequences:
- \ooo
- the character in octal representation
- \0xhh
- the character in hexadecimal representation
- \n
- newline
- \t
- tabulator
Usually the expression arguments given toexprwill be enclosed in single quotes, so I don't expect much confusion withthat backslash quoting.exprwon't place the characters 0x00 or 0x01 inside a string.These characters are silently dropped.
Indexed and non-indexed shell variables are accepted on both sides of anassignment.Indices may be given with either () or [] but if parentheses areused the variable name is first matched again function names.Accessing an non-existing index prints an error message.If a non-indexed variable is a list,expruses the flat string representation of that list.exprdoes not work on lists.
Wildcards
The match operator
~ and the
glob() function use the usualwildcard characters ``
*'', ``
?'' and ``
['' forpattern matching.These wildcard characters cannot be quoted to use them literally in thepattern.This would reintroduce input reinterpretation to the current version of
expr.
expr should work with strings as found in
akanga instead butactually it doesn't.
OPERATORS
The following operators are built into
expr,the list shows the operators in group of equal precedence in order ofdecreasing precedence.
- var #var var[] var()
- variable, number of elements and indexed array variable
- ( )
- expression grouping
- + - ! ~
- unary plus and minus, logical not and binary invert
- * / % ~|
- multiplication, division, modulo and binary xor
- + -
- addition and subtraction
- ^
- string concatenation
- ^~
- string wildcard match
- << >>
- left and right shift
- ^== ^!= ^>= ^> ^< ^<=
- equality, inequality, greater or equal, greater, less and less or equalstring comparisions
- == != >= > < <=
- equality, inequality, greater or equal, greater, less and less or equalnumeric comparisions
- && &
- logical and, binary and
- || |
- logical or, binary and
- ? :
- conditional expression
- ,
- sequential execution
- =
- assignment
The operators behave as in other languages like C orawk(1).Operands with higher precedence are computed first and parentheses canbe used to group expressions.
FUNCTIONS
- argc()
- returns the number of command line arguments.
- argv(k)
- returns the k-th command line argument.
- glob(pattern)
- returns a string listing all filenames matching pattern.The filenames are space separated.
- index(string, sub)
- returns the postion in string at which sub starts or 0 ifsub doesn't appear in string.
- rindex(string, sub)
- returns the rightmost postion in string at which sub starts or0 if sub doesn't appear in string.
- seq(start, end, inc)
- returns a string containing the number sequence beginning from startto end with an increment of inc.The sequence stops if in encouters a value greater than end.
- stat(what, filename)
- returns filesystem information about file depending on what:
- -a
- access time of file.
- -c
- creation time of file.
- -e
- returns true if file exists, otherwise false.
- -g
- group id of file.
- -m
- modification time of file.
- -o
- owner's user id of file.
- -p
- file permision of file as four octal digits.
- -q
- file permision of file as six octal digits.
- -s
- size in bytes of file.
- -u
- device and inode of file.
If what doesn't match the above list the shell printsan error message.If file doesn't exist or the stat(1) call fails for somereason (e.g. insuffient permissions) stat return -1.
Access, creation and modication times are returned in number of secondssince 1.1.1970.
- strftime(format, time)
- return the formatted string of the given time (in seconds from01 January 1970).For a description of format see strftime(3).If time is `1' the current system's time is used.
- strlen(string)
- returns the length of string.
- substr(string, start [, len])
- returns the substring from string string beginning at startwith len characters.
- systime()
- returns the system time in number of seconds from 1970.
- test(condition, file [, listB)
- returns true (1) or false (0) depending on the test condition:
- -b
- true if file is a block device.
- -c
- true if file is a character device.
- -d
- true if file is a directory.
- -e
- true if file exists.
- -f
- true if file is a regular file.
- -g
- true if file has it's setgid bit set.
- -k
- true if file has it's sticky bit set.
- -L
- true if file is a symbolic link.
- -p
- true if file is a named pipe.
- -r
- true if file is readable.
- -s
- true if file is a non-empty regular file.
- -S
- true if file is a socket.
- -u
- true if file has it's setuid bit set.
- -w
- true if file is writeable.
- -x
- true if file is executable.
- -O
- true if file is owned by the effective user id.
- -G
- true if file is owned by the effective group id.
The following binary operations are defined.list may be a space separated list of filenames.If any of the files in list does not exist the expression is false.
- -nt is true is file is newer than each file in list.
- -ot is true if file is older than each file in list.
If any other test condition is given the shell terminates withan error message.
SEE ALSO
rc(1),
akanga(1).
Index
- NAME
- SYNOPSIS
- DESCRIPTION
- OPERANDS
- Wildcards
- OPERATORS
- FUNCTIONS
- SEE ALSO
This document was created byman2html,using the manual pages.