SUBTOTAL

Section: User Commands (1)
Updated: 1. April 1989
 

NAME

subtotal - subtotal values of some columns for fixed values of other columns.  

SYNOPSIS

subtotal by bycolumnlist on oncolumnlist [ < data ]  

DESCRIPTION

subtotal reads columnar data from the standard input and subtotals the by-columns for fixed values of the on-columns.

This is best explained by way of an example. Suppose the file data contains the lines:

x       y       z       v
-       -       -       -
1       1       2       3
1       1       3       4
2       3       4       5
2       4       5       6
2       4       6       7
where exactly one tab-character separates the columns.

The command subtotal by x y on z v < data yields

x       y       z       v
-       -       -       -
1       1       5       7
2       3       4       5
2       4       11      13
on the standard output.

Note that the input must be sorted on the by-columns in some fashion, so that all instances of equivalent lines are adjacent.

On-columns and by-columns can be intermixed in the input. Other columns in the input are ignored in the computations and are not output.  

SEE ALSO

reldb(1), sorttable(1).  

BUGS

Subtotal calls upon two other programs, project and addcol to do the work. This is inefficient but the inefficiency is rarely noticable.RogueMonsterelse
  echo "will not over write ./doc/subtotal.1" fi if `test ! -s ./doc/union.1` then echo "writting ./doc/union.1" cat > ./doc/union.1 << 'RogueMonster'  

NAME

union - appends one table to another  

SYNOPSIS

union file1 file2 [ > outputfile ]  

DESCRIPTION

The union command simply concatenates two files, appending the second to the first, but using only the header of the first file.

With the two files, data1:

first   second  third
-----   ------  -----
1       3       0
1       2       3
and data2:
first   second  third
-----   ------  -----
2       3       4
3       4       5
4       5       6
the command union data1 data2 yields:
first   second  third
-----   ------  -----
1       3       0
1       2       3
2       3       4
3       4       5
4       5       6
on the standard output.

Note that the two input files must have the same columns, in the same order.  

SEE ALSO

reldb(1) cat(1).