Is there a difference in the order of uniq
and sort
when calling them in a shell script? I’m talking here about time- and space-wise.
grep 'somePattern' | uniq | sort
vs.
grep 'somePattern' | sort | uniq
a quick test on a 140 k lines textfile showed a slight speed improvement (5.5 s vs 5.0 s) for the first method (get uniq values and then sort)
I don’t know how to measure memory usage though …
The question now is: does the order make a difference? Or is it dependent on the returned lines from grep (many/few duplicates)