4 ms·
Indeed comm will work much faster than uniq in this case, because it reads each file only once, and does a single pass on each file. What the blog post does (d
by alpb 8y ago
Indeed comm will work much faster than uniq in this case, because it reads each file only once, and does a single pass on each file.
What the blog post does (doing cat multiple times, and then counting the occurrences) is going to be much slower, although mathematically correct.
- fiddlerwoaroof 8y agoDoesn't uniq only read the input once? I've always assumed that the reason uniq assumes its input is presorted is that, then, it doesn't need to buffer all of it: instead, it just eliminates successive duplicate lines.
- alpb 8y agoYeah but in this case the author is doing "cat 1.txt 1.txt 2.txt".