I'm not sure that it's about availability. Most systems I've ever seen have sort
and uniq
as they are usually provided by the same package. I just checked a Solaris system from 2001 and it's sort
has the -u
option.
Technically, using a linux pipe (|
) launches a subshell and is going to be more resource intensive as it requests multiple pid's from the OS.
If you go to the source code for sort
, which comes in the coreutils
package, you can see that it actually just skips printing duplicates as it's printing its own sorted list and doesn't make use of the independent uniq
code.
To see how it works follow the link to sort's source and see the functions below this comment:
/* If uniquified output is turned on, output only the first of an identical series of lines. */
Although I believe sort -u
should be faster, the performance gains are really going to be minimal unless you're running sort | uniq
on huge files, as it will have to read through the entire file again.