[Gllug] simple file matching

n3lly b0y neil at cozyspace.net
Wed Aug 24 08:54:04 UTC 2005


Hello all,

I recently had to match a list of items in one file with that of  
another. The lists were unordered and using diff or comm didn't work  
for me. I don't use perl or python typically so I hit the standard  
bash syntax and summoned:

for i in `cat file1`; do cat file2 | grep "$i" >> matches; done

results were okay (a couple of double entries for some reason) but I  
can't help feeling there was a better way to do this (without  
referring to other scripting languages) - esp. if both lists were  
very large.

How have you unix gurus defeated file/list matching using bash?

Cheers,
n
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2365 bytes
Desc: not available
URL: <http://mailman.lug.org.uk/pipermail/gllug/attachments/20050824/3a5361b6/attachment.bin>
-------------- next part --------------
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug


More information about the GLLUG mailing list