First, intersection sort a.txt B.txt | Uniq-d, and set sort a.txt B.txt | Uniq three, Difference set A.txt-b.txt:sort a.txt b.txt b.txt | Uniq-ub.txt-a.txt:sort B.txt a.txt A.txt | Uniq-u Iv. related explanations use sort to sort files, use lingling after sort, such as-N to sort by number format, such as-I ignores case, for example, use-R for reverse output, etc. uniq to delete duplicate rows in a file, get the only row in the file, followed by the command-D Indicates that the output occurs more than 1 of the content-U represents the output occurrence of 1 of the content, then for the above intersection and set of sets of the command to do the following explanation: Sort a.txt B.txt | Uniq-d: The a.txt b.txt file is sorted, Uniq makes the contents of the two files unique, using the-D output two files more than 1 times the content, that is to get the intersection sort A.txt B.txt | Uniq: a.txt b.txt file is sorted, Uniq makes the contents of two files unique, you can get the set of two files sort a.txt B.txt | Uniq-u: Sort two files, and finally output a.txt b.txt b.txt file only once, because there are two b.txt so only output only once in A.txt, that is a.txt-b.txt difference set for B.txt-a.txt to the same
Linux two files for intersection, set, and difference sets