O'Reilly logo

Linux Shell Scripting Cookbook by Sarath Lakshman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Intersection and set difference (A-B) on text files

Intersection and set difference operations are commonly used in mathematical classes on set theory. However, similar operations on text are also very helpful in some scenarios.

Getting ready

The comm command is a utility to perform comparison between the two files. It has many nice options to arrange the output in such a way that we can perform intersection, difference, and set difference operations.

  • Intersection: The intersection operation will print the lines that the specified files have in common with one another.
  • Difference: The difference operation will print the lines that the specified files contain and that are not the same in all of those files.
  • Set difference: The set difference operation ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required