Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

There are two files with list of names, one name per line. I need to find what names from the second list aren't in the first. Is there some clever way to do it using shell and not "real" programming language?

P.S. I did the comparison using Ruby, but still curious.

share|improve this question
add comment

1 Answer

Try this:

$ grep -vf file1 file2

or:

$ comm -13 <(sort file1) <(sort file2)
share|improve this answer
    
For files of any appreciable size, you will find that your first option will suck in a spectacular fashion. Further, if the files are large and you might conceivably run this comparison more than once, you should sort the input into new files, rather than doing the sort every time you run comm. –  Slartibartfast Sep 14 '11 at 4:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.