Small shell tools for text editing
|
Combining Texts
You use the paste tool for this. Each text file is considered a "column" in the target file. The "montage" works as follows:
paste [FILE1] [FILE2]
You can, of course, direct the output to a new file.
The tool does not in any way evaluate what is on each line. It just pairs them up. Figure 8 shows an example.
Joining Two Files
With the join command, you join the rows of two tables using a common key. The two tables need to be sorted first. To gain a better understanding of how this works, you can take a look at some of the sample files first. The format of the command is join [-OPTION] [FILE1] [FILE2] .
Table 14 shows the most important options. If you omit any field values, the first column of the file is used by default.
Figure 9 shows how join works. In the first example, without any options, the first field is the common key. In the second example, all non-joinable lines in the first file are printed to the output. Finally, all incorrect sorting error messages are removed and the columns for joining get printed. Of course, any further possible pairings are omitted due to any sorting errors.
Buy this article as PDF
Pages: 1
(incl. VAT)