This is best explained by way of an example. Suppose the file data contains the lines:
x y z v u w i - - - - - - - 0 1 2 3 4 * 6 1 2 3 4 5 ** 7 2 3 4 5 6 *** 8 3 4 5 6 7 v 9 4 5 6 7 8 vi 10where exactly one tab-character separates the columns.
The command compute 'z = 2; v=2*i' < data yields
x y z v u w i - - - - - - - 0 1 2 12 4 * 6 1 2 2 14 5 ** 7 2 3 2 16 6 *** 8 3 4 2 18 7 v 9 4 5 2 20 8 vi 10on the standard output.
More complex numerical computation commands can use if-statements, be placed on multiple lines etc. The format of the if-statements is like the expressions described in select(1).
Compute simply calls upon awk to do the work. Any bugs in awk will be reflected in compute.
Since the column names are translated into awk variable names, column names are bound by the same rules as variable names in awk. To be on the safe side, one should only use alphabetic characters and underscores. International characters (e.g. from ISO 8859/1, upper half) will probably not work. Other symbols, such as a hyphen (minus) and asterisk will not work.
Some names are reserved awk symbols and should not be used for column names (e.g. if, for, length).
The single most difficult problem encountered with compute and select is the error messages, which come from within awk. These are hard to trace, as compute and select generate awk-commands, which are stored in a temporary file, and this file is erased immediately after execution.
In BSD, one can suspend compute (with ^Z) immediately after it is started and take a look at the temporary file. Usually the error is completely obvious.
A good-natured soul should add a debug-option to compute and select, to allow output of this temporary file, e.g. to the terminal.