The comm command can tell you what information is common to two lists, and what information appears uniquely in one list or the other. For example, let's say you're compiling information on the favorite movies of critics Siskel and Ebert. The movies are listed in separate files (and must be - if they aren't sorted, the will help). For the sake of illustration, assume each list is short:
To compare the favorite movies of your favorite critics, type:
Column 1 shows the movies that only Siskel likes; Column 2 shows those that only Ebert likes; and Column 3 shows the movies that they both like. You can suppress one or more columns of output by specifying that column as a command-line option. For example, to suppress Columns 1 and 2 (displaying only the movies both critics like), you would type:
As another example, say you've just received a new software release (Release 4), and it's your job to figure out which library functions have been added so that they can be documented along with the old ones. Let's assume you already have a list of the Release 3 functions ( r3_list ) and a list of the Release 4 functions ( r4_list ). (If you didn't, you could create them by changing to the directory that has the function manual pages, listing the files with ls , and saving each list to a file.) In the lists below, we've used letters of the alphabet to represent the functions:
You can now use the comm command to answer several questions you might have:
You can create partial lists by saving the above output to three separate files.
comm can only compare sorted files. If you can't sort the files, look at the trick in article 2.14 : using diff and grep .