Date: December 1998
A little known, but useful, UNIX data manipulation tool is the join command. The function of the join command is similar to a relational database join. It combines common lines from two sorted text files based on a common field. The output of the join command contains common field and the remainder of each line from both files. Unmatched lines are not included in the output.
The following example illustrates the use of the join command. In this example, a hypothetical inventory file is joined with a description file based on the part number. The inventory file is a two column file containing a list of part numbers and its quantity on hand. The description file is a two column file containing the part number and its description. The common field between the two files is the part number, and both files are sorted on the part number.
Note that only the matching lines are displayed. Unmatched lines are discarded. See the man page for the join command for other useful options.