Arithmetic expressions in cdx
support the math.h
part of the C
standard library. That is, you get constants such as M_SQRT2
and functions such as hypot
. Only the function that return a single floating point number are supported, e.g. not sincos
Unary Operators : Leading +
and -
as well as trailing !
(factorial)
Binary Operators : The usual +,-,*,/,%
as well as ^ (power) and the comparison operators <,<=,>,>=,==,!=
which produce 0.0
if false and 1.0
if true.
You canprovide parameters to a function by using a ColumnSet within square brackets. For example max([1-10,~5])
returns the maximum of the first ten columns, except ignoring column 5.
Expressions are used throughout the cdx tools
cdx sort -k ',expr,sin(angle)'
sorts a file by the sin of the value of the ‘angle’ field.cdx cgrep -p ',expr,price*quantity > 100.0'
selects the line where the price
column multiplied by the quantity
column is greater than 100.