[Gllug] Command-line tools for comparing lists

Fred L Youhanaie fly at anydata.co.uk
Thu May 19 12:47:38 UTC 2005


Tom,

Tom Schutzer-Weissmann wrote:
> Another question, and no silly M$ess to crow over either, soz
> 
> I'm looking for command-line tools for comparing lists. For example, to
> find all the lines in a file that also appear in another file, or don't
> appear in another file. Are there some well-established ones, or do
> people just use a bit of Perl / Python / their own poison?

Provided that the two files are sorted in the same order, you can use comm:

to find common lines:
	comm -12 file1 file2
to find lines in file1 but not file2
	comm -23 file1 file2


HTH

Cheers
f.
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list