Comparing two lists

Matthew Seaman m.seaman at infracaninophile.co.uk
Sat May 7 06:38:24 UTC 2011


On 07/05/2011 01:09, Rolf Nielsen wrote:
> I have two text files, quite extensive ones. They have some lines in
> common and some lines are unique to one of the files. The lines that do
> exist in both files are not necessarily in the same location. Now I need
> to compare the files and output a list of lines that exist in both
> files. Is there a simple way to do this? diff? awk? sed? cmp? Or a
> combination of two or more of them?

comm(1)

Which does exactly what you want -- showing lines that belong to one
file or another, and lines that belong to both.  The limitation is that
the files need to be sorted before being compared.

	Cheers,

	Matthew

-- 
Dr Matthew J Seaman MA, D.Phil.                   7 Priory Courtyard
                                                  Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey     Ramsgate
JID: matthew at infracaninophile.co.uk               Kent, CT11 9PW

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 267 bytes
Desc: OpenPGP digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20110507/d4892344/signature.pgp


More information about the freebsd-questions mailing list