11.4. Using join

Join lets you join lines together from two sorted text files. The join command may be familiar to you if you are into SQL.

Here’s how join works. You have two files, file1 and file2, sorted of course. Both files have a common element in them that relates to the other file. Using this relationship, the join ‘folds’ the two files together. It’s a bit like updating a master file, or updating any file that holds elements that are common to both files.

The fields within the text files are normally separated by tabs or spaces, but you can specify another field separator if you like. Some systems say you should not have more than 20 fields in a file when using join; to be honest, if you’ve got more than 20 fields anyway you should ...

Get Linux and Unix Shell Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.