Files
rdb/man/intersect.man

80 lines
1.9 KiB
Groff

.TH intersect "" "" "/rdb Command"
.PC "Write table of rows that are in both input tables"
\fBintersect \fItable1 table2\fR
.PP
.II "
.II sort
.II uniq
.II "table^intersect"
.II "table^logical AND"
.II "intersection of tables"
The command
.B intersect
is a shell script that uses the COHERENT commands
.B sort
and
.B uniq
to perform a logical AND on two tables.
It produces a new table that consists only of the rows that
are in both of the input tables.
The two input tables must have the same number of columns
(called \fIunion compatible\fR), and
rows must match exactly to be considered the same.
.SH Example
Consider the table
.BR journal ,
which appears as follows:
.DM
Date Amount Account Ref Description
------- ------- ------- ------- --------------------------------
820107 14.00 meal v meal with jones
820114 81.80 insur c car insurance allstate
820119 81.72 vitamin c sundown vitamins
820121 20.83 meal v meal with scott
820121 2500.00 keogh c keogh payment
820125 99.00 dues v dues to uni-ops unix conference
.DE
.PP
And consider the table
.BR carexpense ,
which appears as follows:
.DM
Date Amount Account Ref Description
------- ------- ------- ------- --------------------------------
820113 101.62 car v car repairs
820114 81.80 insur c car insurance allstate
820114 93.00 car c car registration dmv
.DE
.PP
To see if any rows in
.B journal
are also in
.BR carexpense ,
type the command:
.DM
intersect journal carexpense
.DE
.PP
In this example, you would see the following on the standard output:
.DM
Date Amount Account Ref Description
------- ------- ------- ------- --------------------------------
820114 81.80 insur c car insurance allstate
.DE
.PP
As you can see, the insurance expense was already posted to the
general journal.
.SH "See Also"
.B
difference,
jointable,
union
.R
.br
COHERENT Lexicon:
.B
sort,
uniq
.R
.SO intersect