5 ms·
Do you know about `comm`? Given two sorted files it will show you in three columns. * unique lines to file1 * unique lines to file2 * lines common
by spudlyo 9y ago
Do you know about `comm`? Given two sorted files it will show you in three columns.
* unique lines to file1
* unique lines to file2
* lines common to both files
You can pass it various options to suppress any of the three columns.
I once had an interview at Facebook where one of the problems was easily solved by `comm`. I found it funny that the interviewer, or anyone who reviewed the interview question, had never heard of it. I was a good sport about it though, I ended up writing a janky Perl script that roughly implemented `comm` to solve the problem, which (modulo Perl) was what they wanted me to do.
- gyrgtyn 9y ago`comm` at least sounds vaguely familiar. Thanks for reminding me; looks useful.
- theoh 9y agoIn that vein, I was asked about implementing n-way merge of logfiles in an interview once. The key insight/recollection they wanted was: use a heap to implement a priority queue. Not sure it was a great question as jumping to employ a data structure like that might suggest premature optimization.