The command [tt]comm[/tt] can be used to compare the files and show you the differences between them. The files need to be sorted first, but [tt]comm[/tt] will give three columns of output, 1) lines only in filea, 2) lines only in fileb, and 3) lines in both files. You can supply a command line option to suppress any of these columns to make a file with what you want.
Assuming they're sorted...
Code:
$ comm fileA fileB
1233
1234
3245
4321
$# Lines common to both
$ comm -12 fileA fileB
1234
3245
4321
$# Lines only in fileB
$ comm -13 fileA fileB
1233
$# Lines only in fileA
$ comm -23 fileA fileB
$
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.